$(init); $.extend($.ligerDefaults.Grid, { rowHeight: 24, fixedCellHeight: false, frozen: false, async: true, headerRowHeight: 30, allowUnSelectRow: true }); //去掉 大于小于包括,并改变顺序 $.ligerDefaults.Filter.operators['string'] = $.ligerDefaults.Filter.operators['text'] = ["like", "equal", "notequal", "startwith", "endwith"]; //扩展一个 数字输入 的编辑器 $.ligerDefaults.Grid.editors['numberbox'] = { create: function (container, editParm) { var column = editParm.column; var precision = column.editor.precision; var input = $(""); input.bind('keypress', function (e) { var keyCode = window.event ? e.keyCode : e.which; return keyCode >= 48 && keyCode <= 57 || keyCode == 46 || keyCode == 8; }); input.bind('blur', function () { var value = input.val(); input.val(parseFloat(value).toFixed(precision)); }); container.append(input); return input; }, getValue: function (input, editParm) { return parseFloat(input.val()); }, setValue: function (input, value, editParm) { var column = editParm.column; var precision = column.editor.precision; input.val(value.toFixed(precision)); }, resize: function (input, width, height, editParm) { input.width(width).height(21); } }; $.ligerDefaults.Grid.editors['string'] = $.ligerDefaults.Grid.editors['text'] = { create: function (container, editParm) { var input = $(""); container.append(input); return input; }, getValue: function (input, editParm) { return input.val(); }, setValue: function (input, value, editParm) { input.val(value); }, resize: function (input, width, height, editParm) { input.width(width).height(21); } }; $.ligerDefaults.Grid.editors['select'] = { create: function (container, editParm) { var column = editParm.column; var input = $("' + (this.text || this.name) + ''); }); return input; }, getValue: function (input, editParm) { return input.val(); }, setValue: function (input, value, editParm) { if (value) input.val(value); }, resize: function (input, width, height, editParm) { input.css({ width: width, height: 22 }); } }; var root = "../../"; var fieldTypeData = [{ value: 'text', text: '文本框' }, { value: 'textarea', text: '多行文本框' }, { value: 'date', text: '日期控件' }, { value: 'select', text: '下拉框' }, { value: 'digits', text: '整数输入框' }, { value: 'number', text: '浮点数输入框' }, { value: 'hidden', text: '隐藏控件'}]; function init() { bulidMainGrid(); } function bulidMainGrid() { var rows = []; $(columns).each(function () { var row = { name: this.text, display: this.text, listwidth: 180, type: 'text', width: 220, labelwidth: 100, space: 30, newline: true, search_newline : false, inlist: true, insearch: false, inform: true, SourceTableName: this.sourceTableName, SourceTableIDField: this.sourceTableIDField, SourceTableTextField: this.sourceTableTextField }; row.allownull = this.isNullable ? true : false; row.type = this.inputType; if (this.isAutoKey || this.isInForeignKey) { row.inlist = false; row.type = "hidden"; } if (row.SourceTableName) { row.type = "select"; } if (this.isAutoKey) { row.insearch = false; } rows.push(row); }); var gridPanle = $('
').appendTo('body'); window.grid = gridPanle.ligerGrid({ columns: [ { display: '基本信息', columns: [ { display: '字段名', name: 'name', align: 'left', width: 110, minWidth: 30 }, { display: '显示名', name: 'display', align: 'left', width: 110, minWidth: 30, editor: { type: 'text'} }, { display: '是否为空', name: 'allownull', width: 55, render: checkboxRender}] }, { display: '列表页设置', columns: [ { display: '列表显示', name: 'inlist', width: 55, render: checkboxRender }, { display: '列表宽度', name: 'listwidth', align: 'right', width: 50, minWidth: 30, editor: { type: 'numberbox'} }, { display: '搜索显示', name: 'insearch', width: 55, render: checkboxRender }, { display: '是否新行', name: 'search_newline', width: 55, render: checkboxRender } ] }, { display: '表单页设置', columns: [ { display: '表单显示', name: 'inform', width: 55, render: checkboxRender }, { display: '控件类型', name: 'type', align: 'left', width: 80, minWidth: 30, editor: { type: 'select', data: fieldTypeData }, render: fieldTypeRender }, { display: '标签宽度', name: 'labelwidth', align: 'right', width: 55, editor: { type: 'numberbox'} }, { display: '控件宽度', name: 'width', align: 'right', width: 55, editor: { type: 'numberbox'} }, { display: '间隔宽度', name: 'space', align: 'right', width: 55, editor: { type: 'numberbox'} }, { display: '是否新行', name: 'newline', width: 55, render: checkboxRender }, { display: '分组', name: 'group', width: 100, editor: { type: 'text'}}] } ],data: { Rows: rows }, usePager: false, toolbar: createGridToolbar(), enabledEdit: true, clickToEdit: true, fixedCellHeight: false, inWindow: false, rownumbers: true, width: '98%', height: '100%',heightDiff:-14, rowHeight: 24 }); } function createGridToolbar(tName) { var items = []; items.push({ text: '预览效果', click: preview, img: "../icons/application_view_list.png" }); items.push({ text: '导出JSON', click: outjson, img: "../icons/printer_48.png" }); items.push({ text: '上移', click: moveup, img: "../icons/sign_up.gif" }); items.push({ text: '下移', click: movedown, img: "../icons/arrow_down.gif" }); //items.push({ text: '自动翻译字段', click: translate, img: "../icons/world.gif" }); return { items: items }; function clear() { var managers = $.ligerui.find($.ligerui.controls.Input); for (var i = 0, l = managers.length; i < l; i++) { if (exits(managers[i].id)) { managers[i].destroy(); } } } function exits(id) { for (var i = 0, l = window.grid.rows.length; i < l; i++) { var name = window.grid.rows[i].name; if (name == id) return true; } return false; } function preview() { clear(); var o = bulidData(); var out = []; out.push('