1

如何使用带有 zfdatagrid 的 ajax 进行编辑行,谢谢

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

1 回答 1

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。

于 2011-08-12T22:30:51.907 回答