示例#1
0
 public function setupFields(Am_Grid_ReadOnly $grid)
 {
     $fields = array();
     //it is special fields and user should not be able to disable or rearrange it
     $fieldCheckboxes = null;
     $fieldActions = null;
     foreach ($grid->getFields() as $field) {
         if ($field->getFieldName() == '_actions') {
             $fieldActions = $field;
             $grid->removeField($field->getFieldName());
             continue;
         }
         if ($field->getFieldName() == '_checkboxes') {
             $fieldCheckboxes = $field;
             $grid->removeField($field->getFieldName());
             continue;
         }
         $this->addField($field);
         $fields[] = $field->getFieldName();
         $grid->removeField($field->getFieldName());
     }
     $this->defaultFields = $fields;
     $fields = $this->getSelectedFields();
     foreach ($fields as $fieldName) {
         if (isset($this->fields[$fieldName])) {
             $grid->addField($this->fields[$fieldName]);
         }
     }
     if ($fieldCheckboxes) {
         $grid->prependField($fieldCheckboxes);
     }
     if ($fieldActions) {
         $grid->addField($fieldActions);
     }
 }