如何验证jquery中的子网格行? [英] How to validate the subgrid rows in jquery?

查看:112
本文介绍了如何验证jquery中的子网格行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个SubGrid。我将在子网格中单击一个链接添加会话,这将向子网格添加行。我可以添加n行数。现在我需要验证子网格中每个添加的行。我该怎么做?



我将代码粘贴到...

  //这是我的jqgrid代码:

function loadSubGrid(subgrid_id,row_id){

DayID = $('#DayEvents')getCell(row_id, '大卫·');
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,页面:d.page,总数:d.total,记录:d。记录},
colNames:['sessionId','session','开始时间','结束时间','Speaker'],
colModel:
[{name:'SessionId ',index:'SessionId',width:90,formatter:'text',align:'center',hidden:true},
{name:'SessionName',index:'SessionName',width: formatter:'text',align:'center',edittype:'text',可编辑: 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).timpericker({})
},dataEvents:[{type:'change',fn:GetRemainingEffort} ,{type:'focus',fn:clearCellValues},{type:'blur',fn:resetCellValues}]}
},
{name:'EndTime',index:'EndTime' :90,formatter:'text',align:'center',edittype:'text',editable:true,editoptions:{size:10,maxlength:15,dataInit:function(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:');}},

打开对话框的功能如下:

 函数Speaker(){


$(#SpeakerPopUp)。对话框('open');

$(#SpeakerPopUp)对话框(
{

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

}

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

解决方案

只需在$(#SpeakerPopUp)对话框('open');

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

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


I am using a SubGrid. I will click a link "add session" in the subgrid which will add rows to the subgrid. I can add n number of rows. Now i need to validate each added rows in the sub grid. How could i do that?

I am pasting my code below...

//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
    });

}

Now in this line in the above code it calls a function to open a dialog box..

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

The function to open the dialog box is below:

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
    }
});
    }

}

Now what i need is it should not open the dialog box if any one of the column in that subgrid row is empty.. Please help me out.. Hope i explained my need clearly..

解决方案

Just insert the following lines in the function speaker before $("#SpeakerPopUp").dialog('open');

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

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

这篇关于如何验证jquery中的子网格行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆