如何编辑单元格Sfdatagrid

时间:2011-06-15 18:49:26

标签: zend-framework zfdatagrid

如何使用ajax和sfdatagrid进行编辑行,谢谢

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));
}

1 个答案:

答案 0 :(得分:0)

如果你还没有在任何地方,你可能想看看jqgrid wiki。它们提供了有关添加内联单元格编辑的信息:

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

以及弹出窗体编辑:

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

根据内联单元格编辑页面,添加cellEdit参数应启用单元格编辑。您可以使用cellurl参数提供数据提交的URL。