Jqgrid使用

 $('#mygrid').jqGrid('GridUnload');   //保留table元素
 $('#mygrid').jqGrid('GridDestroy '); //相当于remove,移除包括table元素

 

 

grid.jqGrid("saveCell", lastrow, lastcell);//保存单元格,切换为文本模式

 

var rowIds = grid.jqGrid('getDataIDs');

for (var i = 0, j = rowIds.length; i < j; i++) {
var curRowData = grid.jqGrid('getRowData', rowIds[i]);
}

grid.setGridParam({ cellEdit: allowEdit });
grid.trigger("reloadGrid");

获取所有选中行

var selectRowIds = grid.jqGrid("getGridParam", "selarrrow");
if (selectRowIds.length < 2) 

 

 var gridColModels = [
    { label: '编号', name: 'Id', index: 'Id', width:100, sortable: false, editable: false,  align: 'center', hidden: true },
    { label: '', name: '', index: '', width: 100, sortable: false, editable: true, align: 'center', edittype: 'text', editrules: { custom: true, custom_func: _dateCheck }, editoptions: { size: 10, maxlengh: 10, dataInit: function (element) { $(element).datepicker({ dateFormat: 'yy-mm-dd' }) } } },
    { label: '', name: '', index: '', width: 100, sortable: false, editable: true, align: 'center', edittype: 'text', editoptions: { size: 10, maxlengh: 10, dataInit: function (element) { $(element).datepicker({ dateFormat: 'yy-mm-dd' }) } } },
    { label: '', name: '', index: '', width: 100, sortable: false, editable: false, align: 'center', formatter: _executeStatusFormatter, unformat: _executeStatusUnFormatter, edittype: 'select', editoptions: { value: { a: 'a', b: 'b' } } },
    { label: '', name: '', index: '', sortable: false, editable: true, align: 'left', edittype: 'text' },
    { label: '', name: '', index: '', sortable: false, editable: false, align: 'left', hidden: true }
    ];
    
    
//验证计划时间格式
function _dateCheck(value, colname) {
    var reg = /^\d{4}-\d{2}-\d{2}$/;
    if (reg.test(value)) {
        return [true, ""];
    }
    else {
        return [false, "必须按格式输入,例如1900-01-01"];
    }
}

function _executeStatusFormatter(cellvalue, options, rowObject) {

    return Utils.StringFormat("<label>{0}</label>", cellvalue);
}
function _executeStatusUnFormatter(cellvalue, options, cell) {
    return $('label', cell).html();
}

 

 

 

posted @ 2014-06-12 18:02    阅读(1122)  评论(0编辑  收藏  举报