检查是否编辑了可编辑字段jqgrid

时间:2012-02-01 12:19:37

标签: jquery jqgrid

当用户在editable中修改textarea jqgrid时,如何跟踪编辑的行?

$("#accJqgrid").jqGrid({
    url: path,
    postData: { deviceId: deviceId, loadId: 'Hardware' },
    datatype: 'json', 
    mtype: 'POST',
    width: 650,
    height: 150,
    colNames: ['', 'ID', '', '', 'Description', '', '', 'Comments', 'Delete'],
    autowidth: true,
    colModel: [
        { name: 'state', width: 30, sortable: false, hidden: true },
        { name: 'ID', width: 30, sortable: false, hidden: true },
        { name: 'catalogId', width: 30, sortable: false, hidden: true },
        { name: 'Save', width: 30, sortable: false, formatter: saveAccessoryData },
        { name: 'Description', width: 250, sortable: false },
        { name: 'Search', width: 30, sortable: false, formatter: searchAccessory },
        { name: 'License', width: 0, sortable: false, hidden: true },
        { name: 'Comments', width: 380, sortable: false, edittype: 'textarea', editable: true, editoptions: { rows: "2", cols: "73", dataInit: function (elem) { $(elem).attr("maxlength", "250"); } } },
        { name: 'Delete', width: 50, sortable: false, edittype: 'checkbox', formatter: 'checkbox', editable: true, align: 'center', classes: 'deleteBackgroundColor' }
    ],
    rowNum: 50,
    pagination: true,
    rowList: [25, 50, 100],
    pager: $('#accJqgridpager'),
    gridComplete: function () {
        }
    },
    afterInsertRow: function (id, data) {
        jQuery('#accJqgrid').jqGrid('editRow', id);
    }
});

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用beforeSelectRow回调来跟踪当前编辑行:

beforeSelectRow: function (rowid) {
    alert('rowid=' + rowid);
}

您的代码有一句话:我建议您不要使用afterInsertRow来缓慢填充jqGrid。您可以在gridview: trueeditRow内添加loadComplete选项并致电gridComplete,而不是loadComplete: function () { var $myGrid = $(this); $myGrid.find('>tbody>tr.jqgrow').each(function () { $myGrid.jqGrid('editRow', this.id); }); }

{{1}}