ligerui_grid使用方法

function f_initGrid()
        {
             g = manager = $("#maingrid").ligerGrid({
              columns:[
              { display: '主键', name: 'ID',width: 50,type: 'int'},
              { display: '名字', name: 'RealName',editor:{type:'text'}},   //editor  编辑器 (可配合detailToEdit使用)
                { display: '性别', width: 50, name: 'Sex',type:'int',
                    editor: { type: 'select', data: sexData, valueColumnName: 'Sex' },  //valueColumnName  编辑器下拉框的默认值
                     render: function (item)
                     {
                         if (parseInt(item.Sex) == 1) return '男';
                         return '女';
                     }
                },
                    { display: '入职日期', name: 'IncomeDay', type: 'date', format: 'yyyy年MM月dd日', width: 100, editor: { type: 'date'}
                    },
                 { display: '部门', name: 'DepartmentID', width: 120, isSort: false,   //isSort  是否允许排序
                                //valueColumnName  对应表格的属性名   displayColumnName  也是对应表格的属性名
                     editor: { type: 'select', data: DepartmentList, valueColumnName: 'DepartmentID', displayColumnName: 'DepartmentName' },
                     render: function (item)
                     {
                         for (var i = 0; i < DepartmentList.length; i++)
                         {
                             if (DepartmentList[i]['DepartmentID'] == item.DepartmentID)
                                 return DepartmentList[i]['DepartmentName']
                         }
                         return item.DepartmentName;
                     }
                },

        //editor 编辑方式文本域属性
                 { display: '地址', name: 'Address',
                     editor: { type: 'textarea',height:60,width:600 }, align: 'left', width: 300
                 } 
              ],
              onSelectRow:function (rowdata,rowindex){
               //alert("onSelectRow!"+rowdata.ID+"------>"+rowindex);
              },
              //enabledEdit:true 是否允许编辑  detailToEdit:true是否启用明细编辑模式
              //isScroll:false  其否启动滚动条   frozen:false是否启动固定列
              //data:EmployeeData,数据源  json格式
              //onBeforeSubmitEdit:f1   编辑器验证
              enabledEdit:true,detailToEdit:true,
              isScroll:false,frozen:false,
              data:EmployeeData,
              width:'100%'
             });
           
        }

你可能感兴趣的:(grid)