如何从子网格rowId中获取父id



我使用的是JqGridsubgrid。我必须从子网格rowId中获取父id

请帮我解决这个问题。。

我正在下面粘贴我的代码。

//这是网格

$("#DayEvents").jqGrid({
    url: 'Event.asmx/GetDayForEvents',
    datatype: 'json',
    mtype: 'POST',
    ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
    serializeGridData: PrepareGridPostData,
    jsonReader: { repeatitems: false, root: "d.rows", page: "d.page", total: "d.total", records: "d.records" },
    colNames: ['day', 'DayID'],
    colModel: [{ name: 'Day', index: 'Day', editable: false, width: 550, align: 'center', sortable: false },
    { name: 'DayID', index: 'DayID', editable: false, width: 550, align: 'center', sortable: false, hidden: true }
  ],
    rowNum: 10,
    rowList: [5, 10, 15, 20],
    // pager: "#pager2",
    viewrecords: true,
    gridview: true,
    width: '100%',
    autowidth: false,
    shrinkToFit: false,
    height: '331px',
    // pgbuttons: true,
    hoverrows: false,
    //caption: 'Days',
    subGrid: true,
    subGridUrl: 'Event.asmx/GetSubGridDay',
    subGridOptions: {
        "plusicon": "ui-icon-triangle-1-e",
        "minusicon": "ui-icon-triangle-1-s",
        "openicon": "ui-icon-arrowreturn-1-e",
        //expand all rows on load
        "expandOnLoad": false
    },

//这是SubgridsubGridRowExpanded:函数(subgid_id,row_id){

        var subgrid_table_id, pager_id;
        subgrid_table_id = subgrid_id + "_t";
        pager_id = "p_" + subgrid_table_id;
        //alert(subgrid_table_id);
        $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><a href=# id='AddSession' OnClick='addRow("" + subgrid_table_id + "");'>add session</a><div id='" + pager_id + "' class='scroll'></div>");
        //debugger;
        jQuery("#" + subgrid_table_id).jqGrid({
            url: 'Event.asmx/GetSubGridDay',
            datatype: 'json',
            mtype: 'POST',
            cellEdit: true,
            cellsubmit: 'clientarray',
            onCellSelect: GridCellClick,               

            ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
            serializeGridData: PrepareGridPostData,
            jsonReader: { repeatitems: false, root: "d.rows", page: "d.page", total: "d.total", records: "d.records" },
            colNames: ['session', 'start time', 'end time'],
            colModel: [
                 { name: 'SessionName', index: 'SessionName', width: 90, formatter: 'text', align: 'center', edittype: 'text', editable: true, editoptions: { size: 10, maxlength: 15, dataEvents: [{ type: 'change', fn: GetRemainingEffort }, { type: 'focus', fn: clearCellValues }, { type: 'blur', fn: resetCellValues}]} },
                  { name: 'StartTime', index: 'StartTime', width: 90, formatter: 'number', align: 'center', edittype: 'text', editable: true, editoptions: { size: 10, maxlength: 15, dataEvents: [{ type: 'change', fn: GetRemainingEffort }, { type: 'focus', fn: clearCellValues }, { type: 'blur', fn: resetCellValues}]} },
                 { name: 'EndTime', index: 'EndTime', width: 90, formatter: 'number', align: 'center', edittype: 'text', editable: true, editoptions: { size: 10, maxlength: 15, dataEvents: [{ type: 'change', fn: GetRemainingEffort }, { type: 'focus', fn: clearCellValues }, { type: 'blur', fn: resetCellValues}]} }
            ],
            rowNum: 10,
             height: 'auto',
            autowidth: true
        });
    }


});

在回调函数subGridRowExpanded内部,您可以使用这个变量,它被初始化为网格的DOM(的DOM)。所以你可以通过this.id.获得父网格的id

检查subGridRowExpanded 的文档

相关内容

  • 没有找到相关文章

最新更新