Documentation

AddRow

object CAdminListRow
CAdminList::&AddRow(
  string $ID[,
  array $arRes = Array(), 
  mixed $link = false, 
  mixed $title = false]
)

The function adds new row to a table. The string is described by the CAdminListRow class instance. This method initialises new instance and returns its link.

Parameters

Parameter Description
ID String unique ID.
arRes List of values as an "parameter"=>"value" array.
link Link, received as the default action for string.
title Text for string pop-up hint.

Example

while($arRes = $rsData->NavNext(true, "f_")):
  
  // create a string. result: CAdminListRow class instance 
  $row =& $lAdmin->AddRow($f_ID, $arRes); 
  
  // then configure value display when viewing and editing a list
  
  // NAME parameter will be edited as text and displayed as a link
  $row->AddInputField("NAME", array("size"=>20));
  $row->AddViewField("NAME", '<a href="rubric_edit.php?ID='.$f_ID.'&lang='.LANG.'">'.$f_NAME.'</a>');
  
  // LID parameter will be edited as language selection dropdown list
  $row->AddEditField("LID", CLang::SelectBox("LID", $f_LID)); 
  
  // SORT parameter will be edited as text
  $row->AddInputField("SORT", array("size"=>20)); 
  
  // ACTIVE and VISIBLE flags will be edited as checkboxes
  $row->AddCheckField("ACTIVE"); 
  $row->AddCheckField("VISIBLE");
  
  // AUTO parameter will be displayed as "Yes" or "No", highlighted as semibold when editing
  $row->AddViewField("AUTO", $f_AUTO=="Y"?GetMessage("POST_U_YES"):GetMessage("POST_U_NO")); 
  $row->AddEditField("AUTO", "<b>".($f_AUTO=="Y"?GetMessage("POST_U_YES"):GetMessage("POST_U_NO"))."</b>");

  // generate context menu 
  $arActions = Array();

  // editing of element
  $arActions[] = array(
    "ICON"=>"edit",
    "DEFAULT"=>true,
    "TEXT"=>GetMessage("rub_edit"),
    "ACTION"=>$lAdmin->ActionRedirect("rubric_edit.php?ID=".$f_ID)
  );
  
  // deleting of element
  if ($POST_RIGHT>="W")
    $arActions[] = array(
      "ICON"=>"delete",
      "TEXT"=>GetMessage("rub_del"),
      "ACTION"=>"if(confirm('".GetMessage('rub_del_conf')."')) ".$lAdmin->ActionDoGroup($f_ID, "delete")
    );

  // insert separator
  $arActions[] = array("SEPARATOR"=>true);

  // check template for auto-generated links
  if (strlen($f_TEMPLATE)>0 && $f_AUTO=="Y")
    $arActions[] = array(
      "ICON"=>"",
      "TEXT"=>GetMessage("rub_check"),
      "ACTION"=>$lAdmin->ActionRedirect("template_test.php?ID=".$f_ID)
    );

  // if the last element - is separator, cleanup the junk.
  if(is_set($arActions[count($arActions)-1], "SEPARATOR"))
    unset($arActions[count($arActions)-1]);
  
  // apply context menu to the string
  $row->AddActions($arActions);

endwhile;


© «Bitrix24», 2001-2022
Up