1

how I can make editing row using ajax with zfdatagrid, thanks

ZF 1.11 -
My Bootstrap

protected function _initZfdatagrid()
{
  $this->_config = new Zend_Config_Ini(APPLICATION_PATH .'/configs/grid.ini', 'production');
  Zend_Registry::set('config', $this->_config);
  if ( @isset(Zend_Registry::get('config')->site->jqGridUrl) ) {
        Bvb_Grid_Deploy_JqGrid::$defaultJqGridLibPath = Zend_Registry::get('config')->site->jqGridUrl;
    }
}

My Controller
public function indexAction()
{
  $grid1 = new Bvb_Grid_Deploy_JqGrid(Zend_Registry::get('config'));
  $this->configG1($grid1);
  $grid1->setDeployOptions(array
           ('title'=>'Grado 10A',
            'subtitle'=>'School2.0 : Matematicas:'.date('Y-m-d'),
            'logo'=>$this->view->baseUrl.'/zfdatagrid/public/images/logotipo.jpg',

                ));
  $this->view->grid = $grid1->deploy();
  $this->render('index');
}

public function configG1 ($grid)
{
$select = $this->_db->select()->from('Articulos', array('id', 'titulo', 'fecha','nota', 'publicar', 'dependencia'));
    $grid->setSource(new Bvb_Grid_Source_Zend_Select($select));
    $grid->updateColumn('id',
            array('title' => '#ID', 'hide' => true));
    $grid->updateColumn('_action',
            array('search' => false, // this will disable search on this field
'order' => 1, 'title' => 'Action', 'width' => 100, 'class' => 'bvb_action bvb_first',     'callback' =>
                array('function' => array($this, 'g1ActionBar'), 'params' =>
                    array('{{ID}}')), 'jqg' =>
                array('fixed' => true, 'search' => false)));
    $grid->updateColumn('titulo', array('title' => 'Titulo Articulo', 'width' => 260));
    $grid->updateColumn('fecha', array('title' => 'Fecha', 'searchType' => "="));
    $grid->updateColumn('Nota', array('title' => 'Calificacion (ucase)', 'callback' => array('function' => create_function('$text', 'return strtoupper($text);'), 'params' => array('{{District}}'))));
    $grid->setDefaultFilters(array('titulo' => '1'));
    $grid->setExport(array(// define parameters for csv export, see Bvb_Grid::getExports
                 'csv' => array('caption' => 'Csv'),
                 'pdf' => array('caption' => 'Pdf')));
    $grid->setJqgParams(array('caption' => 'jqGrid Example', 'forceFit' => true,    'viewrecords' => false, // show/hide record count right bottom in navigation bar
'rowList' => array(10, 20, 30, 40, 50), // show row number per page control in navigation bar
'altRows' => true)// rows will alternate color
);
    $grid->setJqgParam('viewrecords', true); 
    $grid->jqgViewrecords = true; 
    $grid->setBvbParams(array('id' => 'ID'));
    $grid->setBvbParam('id', 'ID'); 
    $grid->bvbId = 'ID'; 
    $grid->bvbOnInit = 'console.log("this message will not be logged because of call to bvbClearOnInit().");';
    $grid->bvbClearOnInit();
    $grid->bvbSetOnInit('console.log("jqGrid initiated ! If data are remote they are not loaded at this point.");');
    $grid->setAjax(get_class($grid));
}
vascowhite
  • 18,120
  • 9
  • 61
  • 77

1 Answers1

0

If you haven't gotten anywhere on this, you might want to look at the jqgrid wiki. They provide information on adding inline cell editing:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing

as well as popup form editing:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing

According to the inline cell editing page, adding the cellEdit parameter should enable cell editing. You can provide the url the data is submit to with the cellurl parameter.

curmil
  • 1,077
  • 13
  • 9