- 注册时间
- 2012-7-23
- 最后登录
- 2014-12-12
- 阅读权限
- 10
- 积分
- 418
- 精华
- 0
- 帖子
- 113
|
为什么我的排序不起作用呢?
还有为什么我的拖动列宽只能拖一次?
- <!--撑满页面-->
- <div class="mini-fit" style="background: red; height: 100px;">
- <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" url="/data/default.aspx?method=SearchEmployees"
- idfield="BrandID" sizelist="[5,10,20,50]" pagesize="20" fitcolumns="false" onload="load()"
- allowcellselect="true" multiselect="true" allowCellEdit="true" oncellbeginedit="OnCellBeginEdit">
- <div property="columns" allowResize="true">
- <div type="indexcolumn" headeralign="center">
- ID</div>
- <div field="BrandID" width="100" headeralign="left" allowSort="true" >
- 编码<input property="editor" class="mini-textbox" vtype="email" style="width: 100%;" /></div>
- <div field="BrandName" width="120" headeralign="left" allowSort="true" >
- 名称<input property="editor" class="mini-textbox" style="width: 100%;" /></div>
- <div field="Description" width="150" headeralign="left" allowSort="true" >
- 描述<input property="editor" class="mini-textbox" style="width: 100%;" /></div>
- <div field="CreateDate" width="150" headeralign="left" dateformat="yyyy-MM-dd hh:mm:ss" allowSort="true" >
- 创建时间</div>
- <div field="LastModDate" width="150" headeralign="left" dateformat="yyyy-MM-dd hh:mm:ss" allowSort="true" >
- 最后修改时间</div>
- </div>
- </div>
- </div>
- <script type="text/javascript">
- mini.parse();
- var grid = mini.get("datagrid1");
- grid.load();
- //搜索按钮事件
- function search() {
- var key = mini.get("key").getValue();
- grid.load({ key: key });
- var datagrid1 = mini.get("datagrid1");
- var data = datagrid1.getData();
- var json = mini.encode(data);
- }
- function OnCellBeginEdit(e) {
- var record = e.record, field = e.field;
- if (field == "BrandID" && record._state != "added") {
- e.cancel = true; //如果修改则不能编辑
- }
- }
- //查询框回车事件
- function onKeyEnter(e) {
- search();
- }
- //新增
- function addRow() {
- var newRow = { name: "New Row" };
- grid.addRow(newRow, 0);
- }
- //修改
- function editRow() {
- var row = grid.getSelected();
-
- if (row) {
- grid.cancelEdit();
- grid.beginEditRow(row);
- } else {
- alert("请选中记录");
- }
- }
- //删除
- function removeRow() {
- var rows = grid.getSelecteds();
- if (rows.length > 0) {
- grid.removeRows(rows, true);
- }
- }
- //保存
- function saveData() {
-
- var data = grid.getChanges();
- var json = mini.encode(data);
- grid.loading("保存中,请稍后......");
- $.ajax({
- url: "/data/default.aspx?method=SaveEmployees",
- data: { data: json },
- type: "post",
- success: function (text) {
- var o = mini.decode(text);
- if (typeof (o.error) != "undefined") {
- alert(o.msg);
- grid.unmask();
- } else {
- grid.reload();
- }
- },
- error: function (jqXHR, textStatus, errorThrown) {
- alert(jqXHR.responseText);
- }
- });
- }
- </script>
复制代码
|
|