JQGrid MultiSelect获取列数据

时间:2010-02-19 14:54:04

标签: javascript jquery jqgrid

有没有办法让JQGrid返回一个列数据数组,以便使用multiSelect而不仅仅是一个rowIds数组?

目前我只能返回所选的最后一列数据。

jQuery("#buttonSelected").click(function() {

           var ids = jQuery("#relatedSearchGrid").getGridParam('selarrrow');
           var count = ids.length;

           for (var i = 0; i < count; i++) {

           var columnData = $("#relatedSearchGrid").find("tbody")[0].rows[$("#relatedSearchGrid").getGridParam('selrow') - 1].cells[1].innerHTML;

               alert("In the loop and  " + columnData );

           }

           if (count == 0) return;
           var posturl = '<%= ResolveUrl("~") %>Rel******/AddSelected****/' + ids;
           if (confirm("Add these " + count + " Docs?")) {
               $.post(posturl,
               { ids: columnData },
               function() { jQuery("#relatedSearchGrid").trigger("reloadGrid") },
            "json");
           }


       })

2 个答案:

答案 0 :(得分:5)

使用getRowData获取每行的数据:

var rowData = $("#relatedSearchGrid").getRowData(ids[i]);

var colData = rowData.Name_Of_Your_Column;

答案 1 :(得分:0)

    var userListjqGrid = $('#UserListGrid'),
        selRowId = userListjqGrid.jqGrid('getGridParam', 'selrow'),
        userId = userListjqGrid.jqGrid('getCell', selRowId, 'UserId'),
        userName = userListjqGrid.jqGrid('getCell', selRowId, 'UserName'),
        subIds = $(subgridTableId).getGridParam('selarrrow'),
        accessRuleIds = [];
    for (var i = 0; i < subIds.length; i++) {
        accessRuleIds[i] = $(subgridTableId).getRowData(subIds[i]).AccessRuleId;
    }