3

在一个单元格中,使用如下键值对选择编辑类型。

 colModel: [
            {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true },
            { name: 'ABC', index: 'ABC', width: '16%', editable: true, edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT"} },
            { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, sortable: true },
            ],

现在在添加新行时,如果我选择了FedEx for ABC列,它会将 FE 发送到 EditURL Link 而不是FedEX,所以我想使用 extraParam 将 FEDEX 发送到 EditURL。

所以请任何人告诉我如何实现它。

为此,我的代码如下

更新代码

var grid = jQuery("#list5").jqGrid({
        url: '/home1/GetUserData',
        datatype: "json",
        mtype: "POST",
        colNames: ['Code', 'LoginID', 'Emailid'],
        colModel: [
                        {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true },
                        { name: 'LoginID', index: 'LoginID', width: '16%', editable: true, sortable: true },
                        { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT"} },
                      ],
        rowNum: 10,
        autowidth: true,
        height: '100%',
        rowList: 10,
        pager: $("#pager2"),
        editurl: "/home1/EditUserData",
        onSelectRow: function (id) {
            if (id && id !== lastsel2) {
                if (id == "new_row") {
                    grid.setGridParam({ editurl: "/home1/InsertUserData" });
                }
                else {
                    grid.setGridParam({ editurl: "/home1/EditUserData" });
                }
                jQuery('#list5').restoreRow(lastsel2);
                jQuery('#list5').jqGrid('editRow', id, true, pickdates);
                $("#list5_ilsave").addClass("ui-state-disabled");
                $("#list5_ilcancel").addClass("ui-state-disabled");
                $("#list5_iladd").removeClass("ui-state-disabled");
                $("#list5_iledit").removeClass("ui-state-disabled");
                lastsel2 = id;
            }
        },
        caption: "Simple data manipulation"
    });
    jQuery("#list5").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: true, search: false, refresh: false }, {}, {}, { url: '/home1/DeleteUserData' });
    jQuery('#list5').jqGrid('inlineNav', '#pager2', { edit: true, add: true, editParams: {extraparam: XYZ()}});
});

function XYZ()
{
  // from here i want to return the text of combo of selected row.
}

更新奥列格的代码

var grid = jQuery("#list5"),
    editingRowId,
    myEditParam = {
        keys: true,
        oneditfunc: function (id) {
            editingRowId = id;
        },
        afterrestorefunc: function (id) {
            editingRowId = undefined;
        },
        extraparam: 
            // we get the text of selected option from the column
            // 'Emailid' and include the data as additional
            // parameter 'EmailidText'
           // EmailidText: function () {
             //   return $("#" + editingRowId + "_Emailid>option:selected").text();
            //}
// **my changes here bind ABC Function which return key , value pair of object** IS THIS POSSIBLE
           function () {
               ABC(); 
            }

    };

grid.jqGrid({
    url: '/home1/GetUserData',
    datatype: "json",
    ...
    onSelectRow: function (id) {
        var $this = $(this), gridIdSelector = '#' + $.jgrid.jqID(this.id);
        $this.jqGrid('setGridParam', {
            editurl: (id === "new_row" ?
                          "/home1/InsertUserData" :
                          "/home1/EditUserData")
        });
        if (editingRowId !== id) {
            $(gridIdSelector + "_iledit").click();
        }
    }
});
$grid.jqGrid('navGrid', '#pager',
    { edit: false, add: false, search: false, refresh: false},
    {}, {}, { url: '/home1/DeleteUserData' });

// inlineNav has restoreAfterSelect: true per default so we don't need to call
// restoreRow explicitly
$grid.jqGrid('inlineNav', '#pager',
    { edit: true, add: true, editParams: myEditParam,
        addParams: {addRowParams: myEditParam } });
4

1 回答 1

6

该代码可能是关于以下

var grid = jQuery("#list5"),
    editingRowId,
    myEditParam = {
        keys: true,
        oneditfunc: function (id) {
            editingRowId = id;
        },
        afterrestorefunc: function (id) {
            editingRowId = undefined;
        },
        extraparam: {
            // we get the text of selected option from the column
            // 'Emailid' and include the data as additional
            // parameter 'EmailidText'
            EmailidText: function () {
                return $("#" + editingRowId + "_Emailid>option:selected").text();
            }
        }
    };

grid.jqGrid({
    url: '/home1/GetUserData',
    datatype: "json",
    ...
    onSelectRow: function (id) {
        var $this = $(this), gridIdSelector = '#' + $.jgrid.jqID(this.id);
        $this.jqGrid('setGridParam', {
            editurl: (id === "new_row" ?
                          "/home1/InsertUserData" :
                          "/home1/EditUserData")
        });
        if (editingRowId !== id) {
            $(gridIdSelector + "_iledit").click();
        }
    }
});
$grid.jqGrid('navGrid', '#pager',
    { edit: false, add: false, search: false, refresh: false},
    {}, {}, { url: '/home1/DeleteUserData' });

// inlineNav has restoreAfterSelect: true per default so we don't need to call
// restoreRow explicitly
$grid.jqGrid('inlineNav', '#pager',
    { edit: true, add: true, editParams: myEditParam,
        addParams: {addRowParams: myEditParam } });
于 2012-05-01T10:51:01.550 回答