JqGrid with Zend Framework (zfdatagrid)

After a couple of days, I could not find a normal answer. Hope someone can help me.

I am using jqGrid in my Zend Framework application. I want this grid in my application to be edited inline ( http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing ). When I do not use ZF, I write jqGrid code (java script) myself - editing embedding works fine. But when using the ZF-class "Bvb_Grid_Deploy_JqGrid" and expanding the grid, ZF independently generates a java script. The problem is that I could not find the ZF method to correctly insert the js "onSelectRow" function. Tried to use "$ grid-> jqAddOnLoad ($ js);" in the ZF controller, but this java script code does not look like in the example, and then the grid does not load normals at all. Must be:

jQuery().ready(function (){
  jQuery("#jqg_RentAsset").jqGrid(
  {
    height: 250,
     ...
    multiselect: true,
    caption: "Manipulating Array Data",
    onSelectRow: function(id)
    {
      alert(id);
    }
  });

But it happens:

$(document).ready(function() {
  jQuery("#jqg_RentAsset").jqGrid(
  {
    onSelectRow: function(id)
    {
      alert(id);
    }
  });
  jQuery("#jqg_RentAsset").jqGrid(
  {
    "height":"250",
      ...
  });

- , ZF-, , , - java script?

+3
2

Zend Framework . , .

, onSelectRow . , , editable: true colModel editurl, . onSelectRow .

setGridParam onSelectRow. :

$(function () {
    var $grid = $("#list"),
        editingRowId,
        myInlineEditingOptions = {
            keys: true,
            oneditfunc: function (id) { editingRowId = id; },
            afterrestorefunc: function () { editingRowId = undefined; },
            aftersavefunc: function () { editingRowId = undefined; }
        };

    $grid.jqGrid({
        datatype: 'local',
        ....
        editurl: 'clientArray'
    });

    // now we set or change onSelectRow callback AFTER jqGrid is created
    $grid.jqGrid('setGridParam', {
        onSelectRow: function (id) {
            if (id !== editingRowId) {
                if (typeof editingRowId !== "undefined") {
                    // save previously editing row
                    //$(this).jqGrid("saveRow", editingRowId, myInlineEditingOptions);

                    // discard changes from the previously editing row
                    $(this).jqGrid("restoreRow", editingRowId, myInlineEditingOptions);
                }
                // start inline editing. The user should save the row by pressing ENTER
                $(this).jqGrid("editRow", id, myInlineEditingOptions);
            }
        }
    });
});

,

  • ( ) onSelectRow , jqGrid.
  • onSelectRow . onSelectRow callback .

. , onSelectRow, onSelectRow . jQuery- , . .

, , jqGridSelectRow onSelectRow.

$(function () {
    var $grid = $("#list"),
        editingRowId,
        myInlineEditingOptions = {
            keys: true,
            oneditfunc: function (id) { editingRowId = id; },
            afterrestorefunc: function () { editingRowId = undefined; },
            aftersavefunc: function () { editingRowId = undefined; }
        };

    $grid.bind("jqGridSelectRow", function (e, id) {
        if (id !== editingRowId) {
            if (typeof editingRowId !== "undefined") {
                // save previously editing row
                //$(this).jqGrid("saveRow", editingRowId, myInlineEditingOptions);

                // discard changes from the previously editing row
                $(this).jqGrid("restoreRow", editingRowId, myInlineEditingOptions);
            }
            // start inline editing. The user should save the row by pressing ENTER
            $(this).jqGrid("editRow", id, myInlineEditingOptions);
        }
    });

    $grid.jqGrid({
        datatype: 'local',
        ....
        editurl: 'clientArray'
    });
});

. , . . $grid.bind("jqGridSelectRow.myNamespace", ...);, $grid.unbind('.myNamespace'); $grid.unbind('jqGridSelectRow.myNamespace');. , .

+2

. java script "onSelectRow" ZF ( phtml), :

<?php $this->headScript()->captureStart() ?>
$(document).ready(function() {
    var lastSel;
    jQuery("#jqg_RentAsset").jqGrid('setGridParam', {
        onSelectRow: function(id)
        { 
            alert(id);
        }
    });
});
<?php $this->headScript()->captureEnd() ?>

. "setGridParam" "$ grid- > jqAddOnLoad ($ js);" ZF. , , . . , , "$ grid- > setParams (array)"... .:)

0

All Articles