easyui datagrid

本小妞迷上赌 提交于 2019-12-20 17:52:54

http://www.jeasyuicn.com/sort/extend/

1获取选择行  var rows = $('#tt').datagrid('getSelected');

2获取所在行function getRowIndex(target) {$(target).closest('tr.datagrid-row'); return

parseInt(tr.attr('datagrid-row-index'));}

3获取所有行 var row = $('#tt').datagrid(‘getRows’);

4修改某行$('#tt').datagrid('updateRow',{index:rowIndex,row: response.data.data});

5行状态为可编辑$('#tt').datagrid('beginEdit', rowIndex);

6 获取修改行的修改值和原来值

var ed = $('#tt').datagrid('getEditors',rowIndex);

var d0=jQuery(ed[0].target).val();

jQuery(ed[0].target).val(ed[0].oldHtml);

7 修改单元格值$(target).closest('div').html(s);

8 删除行$('#tt').datagrid('deleteRow', getRowIndex(target));    

9 给datagrid赋值$('#tt').datagrid('loadData',response.data.data);

10增加一行

复制代码
    var roomtype ={};
    roomtype.rtName =rmtyname;
    roomtype.rtCode =code;
    var reservation ={};
    reservation.revArrivedate =stdate;
    reservation.revLeavedate =edate;
    $('#recode').datagrid("insertRow",{
        index:0,
        row:{'roomtype':roomtype,'rrosum':num,'rroCount':count,'rroPrice':rmprice,'reservation':reservation}
     });
复制代码

 11 取消选中

$('#reserveList').datagrid('clearSelections');//取消选中
$("#reserveList").datagrid('selectRecord', name);//选中fieldId$('#tt').datagrid("selectRow", 0);
if($('#reserveList').datagrid("getSelected") == null)//选中值判断

 

 

Checkbox控制:$(target).closest('tr.datagrid-row').find(':checkbox').attr('disabled',false);

$("#frid").attr("checked", true);

 

 

    function initRmtype(){

        $.ajax({

            type : 'POST',

            url : 'roomstate/roompriceAction/getRoomTypeList',

            dataType : 'json',

            timeout : 30000,// 超时时间设定

            data : ({}),

            error : function(xhr, textStatus, thrownError) {

                if (xhr.readyState != 0 && xhr.readyState != 1) {

                    alert("查询失败, 错误号:  " + xhr.status + ", 错误信息: "

                            + textStatus);

                } else {

                    alert("查询失败,错误信息:  " + textStatus);

                }

           

            },

            success : function(response) {

                if (response.result == 'ok'){

                    if(response.data.data.rows.length>0){

                        $('#tt').datagrid('loadData',response.data.data);

                    }

                }

            }

        });

}

 

$('#tt').datagrid({

                height:200,        // 设置高度

                singleSelect:true, // 设置单选

                pagination: false, // 设置表格是否使用分页

                fitColumns: true,  // 设置表格列是否自适应表格宽度

                remoteSort:false,  // 设置可排序

                rownumbers: true,  // 显示行号

                frozenColumns:[[ {field:'ck',checkbox:true,align:'center'}]], //显示checkbox

                idField:'rpId',

                columns:[[

                    {field :'rpId', title : 'id', width : 10,hidden:'true'},

                    {field:'roomtype.rtName',title:'房型名称',width:160,formatter:function(value,row,index){return row.roomtype.rtName;},editor:{type:'validatebox',options:{required:true,validType:'length[1,30]'}}},

                    {field:'roomtype.rtCode',title:'简称',width:180,align: "center",sortable : true},

                    {field:'rpWflag',title:'星期',width:180,align:'center',

                    formatter:function(value,row,index){

                            var c =' checked';

                            var e = '<input type="checkbox" name="frid" id="week" disabled ';

                            if(value==2||value==3){

                                e=e+c;

                            }

                            e += '/>星期五&nbsp;&nbsp;<input type="checkbox" name="satr" id="week" disabled ';

                            if(value==1||value==3){

                                e=e+c;

                            }

                            e +='/>星期六';

                            return e;

                    }

                    },

                    {field:'action',title:'操作',width:80,align:'center',

                        formatter:function(value,row,index){

                                var e = '<a href="javascript:void(0);" onclick="insert(0,this)">编辑</a> '+'<a href="javascript:void(0);" onclick="deleterow(this)">删除</a>';

                                return e;

                        }

                    }

                ]],onClickRow: function (rowIndex) {

                    LoadRoomList();

                }

            });

            initRmtype();

     });

http://www.jeasyuicn.com/sort/extend/

1获取选择行  var rows = $('#tt').datagrid('getSelected');

2获取所在行function getRowIndex(target) {$(target).closest('tr.datagrid-row'); return

parseInt(tr.attr('datagrid-row-index'));}

3获取所有行 var row = $('#tt').datagrid(‘getRows’);

4修改某行$('#tt').datagrid('updateRow',{index:rowIndex,row: response.data.data});

5行状态为可编辑$('#tt').datagrid('beginEdit', rowIndex);

6 获取修改行的修改值和原来值

var ed = $('#tt').datagrid('getEditors',rowIndex);

var d0=jQuery(ed[0].target).val();

jQuery(ed[0].target).val(ed[0].oldHtml);

7 修改单元格值$(target).closest('div').html(s);

8 删除行$('#tt').datagrid('deleteRow', getRowIndex(target));    

9 给datagrid赋值$('#tt').datagrid('loadData',response.data.data);

10增加一行

复制代码
    var roomtype ={};
    roomtype.rtName =rmtyname;
    roomtype.rtCode =code;
    var reservation ={};
    reservation.revArrivedate =stdate;
    reservation.revLeavedate =edate;
    $('#recode').datagrid("insertRow",{
        index:0,
        row:{'roomtype':roomtype,'rrosum':num,'rroCount':count,'rroPrice':rmprice,'reservation':reservation}
     });
复制代码

 11 取消选中

$('#reserveList').datagrid('clearSelections');//取消选中
$("#reserveList").datagrid('selectRecord', name);//选中fieldId$('#tt').datagrid("selectRow", 0);
if($('#reserveList').datagrid("getSelected") == null)//选中值判断

 

 

Checkbox控制:$(target).closest('tr.datagrid-row').find(':checkbox').attr('disabled',false);

$("#frid").attr("checked", true);

 

 

    function initRmtype(){

        $.ajax({

            type : 'POST',

            url : 'roomstate/roompriceAction/getRoomTypeList',

            dataType : 'json',

            timeout : 30000,// 超时时间设定

            data : ({}),

            error : function(xhr, textStatus, thrownError) {

                if (xhr.readyState != 0 && xhr.readyState != 1) {

                    alert("查询失败, 错误号:  " + xhr.status + ", 错误信息: "

                            + textStatus);

                } else {

                    alert("查询失败,错误信息:  " + textStatus);

                }

           

            },

            success : function(response) {

                if (response.result == 'ok'){

                    if(response.data.data.rows.length>0){

                        $('#tt').datagrid('loadData',response.data.data);

                    }

                }

            }

        });

}

 

$('#tt').datagrid({

                height:200,        // 设置高度

                singleSelect:true, // 设置单选

                pagination: false, // 设置表格是否使用分页

                fitColumns: true,  // 设置表格列是否自适应表格宽度

                remoteSort:false,  // 设置可排序

                rownumbers: true,  // 显示行号

                frozenColumns:[[ {field:'ck',checkbox:true,align:'center'}]], //显示checkbox

                idField:'rpId',

                columns:[[

                    {field :'rpId', title : 'id', width : 10,hidden:'true'},

                    {field:'roomtype.rtName',title:'房型名称',width:160,formatter:function(value,row,index){return row.roomtype.rtName;},editor:{type:'validatebox',options:{required:true,validType:'length[1,30]'}}},

                    {field:'roomtype.rtCode',title:'简称',width:180,align: "center",sortable : true},

                    {field:'rpWflag',title:'星期',width:180,align:'center',

                    formatter:function(value,row,index){

                            var c =' checked';

                            var e = '<input type="checkbox" name="frid" id="week" disabled ';

                            if(value==2||value==3){

                                e=e+c;

                            }

                            e += '/>星期五&nbsp;&nbsp;<input type="checkbox" name="satr" id="week" disabled ';

                            if(value==1||value==3){

                                e=e+c;

                            }

                            e +='/>星期六';

                            return e;

                    }

                    },

                    {field:'action',title:'操作',width:80,align:'center',

                        formatter:function(value,row,index){

                                var e = '<a href="javascript:void(0);" onclick="insert(0,this)">编辑</a> '+'<a href="javascript:void(0);" onclick="deleterow(this)">删除</a>';

                                return e;

                        }

                    }

                ]],onClickRow: function (rowIndex) {

                    LoadRoomList();

                }

            });

            initRmtype();

     });

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!