1.阻止cell编辑

config.onEditorPreparing = function (e) {
if (e.dataField === 'xx' && e.row.data.Id) {//判断是否是某一列
e.cancel = true;
return;
}
};

2.配置子项

config.masterDetail = {
enabled: true,
template: function (container, info) {
var detailConfig = getProjectContactsConfig(info.data);//JSON.stringify(info.data)
detailConfig.masterRow = info.data;//缓存父级row对象给detailGrid
detailConfig.gridId = 'master-grid-Proj-' + info.data.Id;
var $grid=$('<div id="' + detailConfig.gridId +'">').dxDataGrid(detailConfig);
detailConfig.component = $grid.dxDataGrid('instance');//$(detailConfig.gridSelector).dxDataGrid('instance');
$grid.appendTo(container);
}
};

  3.编辑新行注意事项和选中行事件

config.onInitNewRow = function (e) {
e.data.ProjId = row.Id;
};//编辑新行时父Id赋值 config.onRowClick = function (e) {
if (e.rowType !== "totalFooter") {
e.component.selectRows();
e.component.selectRowsByIndexes(e.component.getRowIndexByKey(e.key));
}
};//选中行事件

4.第一行选中

config.onContentReady = function (e) {
//默认选中控件第一行
if (e.component.getVisibleRows().length > 0)
e.component.selectRows(e.component.getVisibleRows()[0].key);
};

5.时间值可编辑时要在config初始化时格式转换

var config = dxConfig.editGrid({
url: '/XXX',
id: id,
onLoaded: function(res) {
if (res.data.data) {
$.each(res.data.data, function(rIndex, rRow) {
if (rRow && rRow.StartDate) rRow.StartDate = T(rRow.StartDate, __DateFormat);
if (rRow && rRow.EndDate) rRow.EndDate = T(rRow.EndDate,__DateFormat);
});
}
}});//其中的__DateFormat是时间格式YYYY/MM/DD等

6. 字段下拉设置

{
dataField: "SupProjId",
caption: "xxx",
allowSorting: false,
allowHeaderFiltering: false,
alignment: "left",
editorOptions: {
showClearButton: true,
valueExpr: "Value",//选中值
displayExpr: "Text"//显示值
},
cellTemplate: function (ele, info) {
if (info.data) {
ele.html(info.data.Name);//显示值
}
}

  3.编辑模式:

config.editing.mode = 'batch';//可多行编辑右上角含保存按钮,保存后按钮不可编辑,只有内容更改时可保存
config.editing.mode = 'cell';列编辑可直接保存

config.editing.mode = 'form';//表单编辑

config.editing.mode = 'popup';弹出编辑
editing: {
mode: "popup",
allowUpdating: true,
popup: {
title: "Employee Info",
showTitle: true,
width: 700,
height: 525,
position: {
my: "top",
at: "top",
of: window
}
},
form: {
items: [{
itemType: "group",
colCount: 2,
colSpan: 2,
items: ["FirstName", "LastName", "Prefix", "BirthDate", "Position", "HireDate", {
dataField: "Notes",
editorType: "dxTextArea",
colSpan: 2,
editorOptions: {
height: 100
}
}]
}, {
itemType: "group",
colCount: 2,
colSpan: 2,
caption: "Home Address",
items: ["StateID", "Address"]
}]
}
}

  

edtingmode='row'//行编辑

  

 

  

DevExtreme学习笔记(一) DataGrid中注意事项的更多相关文章

  1. DevExtreme学习笔记(一) DataGrid中数据提交注意事项

    1.数据提交的{}数据需转化json格式 syncPost('/controller/action', { values: JSON.stringify({d:x}) }, function (res ...

  2. DevExtreme学习笔记(一) DataGrid中MVC分析

    @(Html.DevExtreme().DataGrid() .ID("gridContainer") .DataSource(d => d .OData() .Url(&q ...

  3. DevExtreme学习笔记(一) DataGrid中数据筛选

    config.filterRow = { visible: true, applyFilter: "auto" }; config.headerFilter = { visible ...

  4. DevExtreme学习笔记(一) DataGrid中js分析

    1.overviewjs采用 $(function() { $("#gridContainer").dxDataGrid({ dataSource: { store: { type ...

  5. 并发编程学习笔记(4)----jdk5中提供的原子类及Lock使用及原理

    (1)jdk中原子类的使用: jdk5中提供了很多原子类,它会使变量的操作变成原子性的. 原子性:原子性指的是一个操作是不可中断的,即使是在多个线程一起操作的情况下,一个操作一旦开始,就不会被其他线程 ...

  6. [学习笔记] 在Eclipse中导入项目

    参考前文:[学习笔记] 在Eclips 中导出项目 选择已经导出的文件: 导入之后,项目结构如下: 至此,完成.

  7. CockroachDB学习笔记——[译]CockroachDB中的SQL:映射表中数据到键值存储

    CockroachDB学习笔记--[译]CockroachDB中的SQL:映射表中数据到键值存储 原文标题:SQL in CockroachDB: Mapping Table Data to Key- ...

  8. [学习笔记] 在Eclipse中导出可以直接运行的jar,依赖的jar中的类解压后放在运行jar中

    前文: [学习笔记] 在Eclipse中导出可以直接运行的jar,依赖的jar打在jar包中 使用7z打开压缩包,查看所有依赖的jar都被解压以包名及class的方式存储在了运行jar中,此时jar的 ...

  9. [学习笔记] 在Eclipse中导出可以直接运行的jar,依赖的jar打在jar包中

    本文需要参考前文: [学习笔记] 在Eclipse中导出可以直接运行的jar,依赖的jar在子目录中 上文是导出的运行的依赖jar被放在了子目录中,本文是将依赖jar放在可运行jar的本身,这样发布的 ...

随机推荐

  1. HttpClient 发送请求和参数

    发送请求 没有参数 private static void getData() { String timeStamp = String.valueOf(System.currentTimeMillis ...

  2. 帝国CMS 7.5编辑器从WORD中粘贴过来无法保留格式和图片的解决办法

      配置过滤js文件 首先打开  \editor\plugins\pastefromword\filter\default.js  在文件的最后部分又如下代码(修改前的代码),也可以搜索CKEDITO ...

  3. vue+elementui搭建后台管理界面(6登录和菜单权限控制)

    不同的权限对应不同的路由(菜单),同时侧边栏也根据权限异步生成,实现登录和鉴权思路如下: 登录:点击登录,服务器验证通过后返回一个 token ,然后存到 cookie,再根据 token 拉取用户权 ...

  4. 【CNN】--- 卷积过程中RGB与灰度的区别

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/hacker_Dem_br/article/ ...

  5. C#中将xml文件反序列化为实例时采用基类还是派生类的问题

    基类: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...

  6. sqlite数据库使用具体案例以及mysqlite.db数据库

    本文操作是测试数据库的其中一张表,其中包括清空sqlite数据库MyGroup表中的数据,清空sqlite数据库sqlite_sequence表中的自增变量,sqlite数据库MyGroup直接插入数 ...

  7. grandle Project sync failed.please fix your project and try again

    Android Studio导入项目或者新建项目想运行的时候可能会报错Gradle project sync failed. Please fix your project and try again ...

  8. Qt 图片缩放参数计算

    缩放图片 void VCImgWidget::wheelEvent(QWheelEvent *event) { ) { // 当滚轮远离使用者时 //ui->textEdit->zoomI ...

  9. Excel 相当名称,值相加

    药品名称相同,数量汇总 原始表格,同一个名称,存在不同的单位,所以合并处理成一列 将列表复制一份出去,并删除A表重复数据 求和公式=SUMIF(A2:A16,E2:E8,B2:B16) 最后再将药品名 ...

  10. Python 初级 6 循环 (三)

    一.复习 1 计算循环(for循环) for looper in [1, 2, 3, 4, 5]: print("hello") 1) looper的值从第0个数1开始 2) 对应 ...