如何在onClickButton中传递rowId值:js中的函数...我的代码如下

时间:2018-06-22 04:34:12

标签: javascript jqgrid

  }).navGrid("#DashboardPager", { edit: false, add: false, del: false ,save:false}, {}, {}, {}, { modal: true, multipleSearch: true })

    $grid.jqGrid('inlineNav', '#DashboardPager', {



        onClickButton: function () {
            debugger;



            edit: true;

            add: false;
            del: false;
            cancel: true;
            save: false;
            editParams: {
                    keys: false;
      };
            addParams: {
                keys: false;


                }
        },
    }), 

    $grid.navButtonAdd('#DashboardPager', {              

 buttonicon: "ui-icon-disk",
        jsonReader: "{repeatitems:false}",
        onClickButton: function (rowId) {



            var selRowId = null;
            var myGrid = $('#DashboardTable'),
            selRowId = myGrid.jqGrid('getRowData', rowId);
            var Project_ID = selRowId['PROJECT_ID'];
            var Status = selRowId['PROJECT_STATUS'];

            $.ajax({
                type: "POST",
                data: "{projectID:'" + projectID + "', Status:'" + Status + "'}",
                url: "Home.aspx/Operation",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
            });

    },
        title: "Export to Excel with Filter",
        position: "first"
    });
}

1 个答案:

答案 0 :(得分:0)

没有rowId方法的onClickButton回调的navButtonAdd参数。我建议您使用

var rowId = myGrid.jqGrid("getGridParam", "selrow");

onClickButton回调的代码内以获取当前选定行的ID。