easyuidatagrid的行编辑器editor如何实现新增时可修改,编辑时,不可修改

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

easyuidatagrid的⾏编辑器editor如何实现新增时可修改,编辑时,不可修改
项⽬出现⼀个需求,要求⽤户界⾯的⽤户名,新增时,可⾃由输⼊,编辑时,不可修改
html页⾯
<table id="gridlist" data-bind="datagrid:grid">
<thead>
<tr>
<th field="ck" checkbox="true" readOnly:true ></th>
<th field="OptimisticLockField" hidden="true"></th>
<th field="UserCode" sortable="true" align="left" width="80" editor="{type:'validatebox',options:{required: true }}">⽤户名</th>
<th field="UserName" sortable="true" align="left" width="200" editor="{type:'validatebox',options:{required: true }}">名称</th>
<th field="OriginalPassword" sortable="true" align="left" width="200">密码</th>
<th field="Org" sortable="true" align="left" width="200" editor="{type:'lookup',options:{required:true,lookupType:'cloud.PcsOrg',window:{title:'所属机构'},queryParams:{State:9,Ou:false}}}" formatter="formatOrg">所属机构<th field="IsEnable" sortable="true" align="center" width="120" editor="{type:'checkbox',options:{on:1,off:0}}" formatter="com.formatCheckbox">是否可⽤</th>
<th field="IsAdmin" align="center" width="120" editor="{type:'checkbox',options:{on:1,off:0}}" formatter="com.formatCheckbox">是否管理员</th>
<th field="LoginCount" sortable="true" align="right" width="120">登录次数</th>
<th field="LastLoginDate" sortable="true" align="left" width="135" formatter="com.formatDate">最后登录⽇期</th>
<th field="LastLoginOU" align="left" width="170" hidden="true">最后登录组织</th>
<th field="OrganizeNames" align="left" width="170">最后登录组织</th>
<th field="Permit" align="center" width="320" formatter="formatterButton">操作</th>
<th field="Description" align="left" width="150" editor="text">描述</th>
</tr>
</thead>
</table>
原先编辑⽅法
//原先编辑⽅法
this.editClick = function () {
if (self.RowsCount() > 1) return;
var row = self.grid.datagrid('getSelected');
if (row == null) {
com.message('error', "请选中需编辑的⼀⾏数据");
return;
}
var index = self.grid.datagrid('getRowIndex', row);
self.gridEdit.begin(index, row);
self.viewType = v_edit;
self.IsViewType(v_edit);
};
新的编辑⽅法
//新的编辑⽅法
this.editClick = function () {
if (self.RowsCount() > 1) return;
var row = self.grid.datagrid('getSelected');
if (row == null) {
com.message('error', "请选中需编辑的⼀⾏数据");
return;
}
//在编辑后把⽤户名改为查看状态
if (row._isnew == undefined) {
//编辑的时候把⽤户名改为查看状态
$('#gridlist').datagrid('removeEditor', 'UserCode');
}
var index = self.grid.datagrid('getRowIndex', row);
self.gridEdit.begin(index, row);
self.viewType = v_edit;
self.IsViewType(v_edit);
};
页⾯效果
1)新增时
2)编辑时
总结:使⽤ datagrid的removeEditor⽅法,指定对应列名,如语法: $('#gridlist').datagrid('removeEditor', 'UserCode');。

相关文档
最新文档