如何验证jQuery中次网格行?(How to validate the subgrid rows

2019-10-17 04:59发布

我使用的是子网格。 我会点击一个链接中,将行添加到子网格的子网格“添加会议”。 我可以添加行的n个。 现在我需要在子网格验证每个添加的行。 我怎么能这样做?

我下面粘贴我的代码...

//This is my jqgrid code:

function loadSubGrid(subgrid_id, row_id) {

   DayID = $('#DayEvents').getCell(row_id, 'DayID');
    var pager_id;
    subgrid_table_id = subgrid_id + "_t";
    pager_id = "p_" + 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>");

    jQuery("#" + subgrid_table_id).jqGrid({
        url: 'Event.asmx/GetSubGridDay',
        datatype: 'json',
        mtype: 'POST',
        cellEdit: false,
        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: ['sessionId', 'session', 'start time', 'end time', 'Speaker'],
        colModel:
                          [{ name: 'SessionId', index: 'SessionId', width: 90, formatter: 'text', align: 'center', hidden: true },
                          { 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: 'text', align: 'center', edittype: 'text', editable: true, editoptions: { size: 10, maxlength: 15, dataInit: function(element) {
                              $(element).timepicker({})
                          }, dataEvents: [{ type: 'change', fn: GetRemainingEffort }, { type: 'focus', fn: clearCellValues }, { type: 'blur', fn: resetCellValues}]}
                          },
                          { name: 'EndTime', index: 'EndTime', width: 90, formatter: 'text', align: 'center', edittype: 'text', editable: true, editoptions: { size: 10, maxlength: 15, dataInit: function(element) {
                              $(element).timepicker({})
                          }, dataEvents: [{ type: 'change', fn: GetRemainingEffort }, { type: 'focus', fn: clearCellValues }, { type: 'blur', fn: resetCellValues}]}
                          },

                            { name: 'Speaker', index: 'Speaker', width: 300, editable: false, formatter: 'showlink', formatoptions: { baseLinkUrl: 'javascript:', showAction: "Speaker('", addParam: "');"} },


                          ],
        rowNum: 10,
        height: 'auto',
        autowidth: true
    });

}

现在,在这条线在上面的代码调用一个函数打开一个对话框..

 { name: 'Speaker', index: 'Speaker', width: 300, editable: false, formatter: 'showlink', formatoptions: { baseLinkUrl: 'javascript:', showAction: "Speaker('", addParam: "');"} },

打开对话框功能如下:

function Speaker() {


        $("#SpeakerPopUp").dialog('open');

        $("#SpeakerPopUp").dialog(
{

    autoOpen: true,
    height: 500,
    width: 500,
    modal: true,
    title: 'Speakers List',
    open: gridData,
    buttons: {
        'cancel': function CancelCheck() { $(this).dialog('close'); },
        'Save': SpeakerSelectionSave
    }
});
    }

}

现在,我需要的是它不应该打开的对话框中,如果是子网格行中的列中的任何一个是空的。请帮我..希望我解释清楚我的需要..

Answer 1:

就在$前插入功能扬声器以下行(“#SpeakerPopUp”)对话框(“开放”)。

     if (_lastSelRow == null) { alert("enter all"); }
            else {

                alert("test" + _lastSelRow);
                if (($('#' + _lastSelRow + '_SessionName').val() == "") || ($('#' + _lastSelRow + '_StartTime').val() == "") || ($('#' + _lastSelRow + 'EndTime').val() == "")) 
else
{
///


文章来源: How to validate the subgrid rows in jquery?