功能要求如图所示:

function Loading() {
var editRow = undefined;//保存行的索引
var query= $("#myform").serializeObject();
$("#tabTopicList").datagrid({
url: 'Tools/GetTopicList.ashx',
queryParams:query,
pagination: true,
width: ,
height:,
pageSize: ,
pageList: [, ],
fit: true,
fitColumns: true,
nowarp: false,
idField: 'top_id',
sortName: 'top_createtime',
sortOrder: 'desc',
columns: [[
{ field: 'cbx', checkbox: true },
{
title: '类别',
field: 'cat_title',
width:,
editor: {
type: 'combobox',
options: {
required: true,
missingMessage: '请选择类别',
url: 'Tools/GetTopicCategory.ashx',
valueField: 'Cat_Id',
textField: 'Cat_Title',
onSelect: function (record) {
//重点在此处
//先获取到当前选中行
//根据当前行获取,当前行的下标
//在根据下标和要获取列的filed获取对应filed的Editor对象
//然后在根据对应的Editor操作
var row = $("#tabTopicList").datagrid('getSelected');
var rindex = $("#tabTopicList").datagrid('getRowIndex', row);
console.log(rindex);
var ed = $("#tabTopicList").datagrid('getEditor', {
index: rindex,
field: 'cat_title'
});
console.log($(ed.target).combobox('getText'));
var msg = $(ed.target).combobox('getText'); if (msg == '单选题') {
console.log();
var rows = getEditRow(rindex, 'top_answer');
//这里能对答案的combobox赋值为2
//$(rows.target).combobox('setValues','2');
//这里我以为能这样操作,
//既然可以操作方法, 为什么就不能重新定义data数据呢
//$(rows.target).combobox({
// data:[{
// label: 'A',
// value:'A'
// }, {
// label: 'B',
// value: 'B'
// },{
// label: 'C',
// value: 'C'
// }, {
// label: 'D',
// value: 'D'
// }]
//});
} else if (msg == '多选题') {
console.log();
var rows = getEditRow(rindex, 'top_answer');
$(rows.target).combobox('setValues', '');
}
}, }
}
},
{
title: '题目',
field: 'top_description',
width: ,
editor: {
type: 'validatebox',
options: {
required: true,
missingMessage: '请输入题目'
}
} },
{
title: '选项A',
field: 'top_answera',
width: ,
editor: {
type: 'validatebox',
options: {
required: true,
missingMessage:'请输入选项A'
}
}
},
{
title: '选项B',
field: 'top_answerb',
width: ,
editor: {
type: 'validatebox',
options: {
required: true,
missingMessage: '请输入选项B'
}
}
},
{
title: '选项C',
field: 'top_answerc',
width: ,
editor: {
type: 'validatebox',
options: {
required: true,
missingMessage: '请输入选项C'
}
}
},
{
title: '选项D',
field: 'top_answerd',
width: ,
editor: {
type: 'validatebox',
options: {
required: true,
missingMessage: '请输入选项D'
}
}
},
{
title: '答案',
field: 'top_answer',
width: ,
editor: {
type: 'combobox',
options: {
required: true,
missingMessage: '请选择答案',
multiple: true,
editable: false,
valueField: 'label',
textField: 'value',
formatter:function (row) {
//console.log(row);
return "<input type=\"checkbox\" name=\"" + row.label + "\" id=\"" + row.value + "\"/>" + row.value;
},
onSelect:function (rec) {
//console.log(rec.value);
$("#" + rec.value).attr("checked", "checked");
},
onUnselect: function (rec) {
$("#" + rec.value).removeAttr("checked");
},
}
}
}, {
title: '类型',
field: 'top_name',
width: ,
editor: {
type: 'combobox',
options: {
required: true,
missingMessage: '请选择类型',
multiple: true,
editable: false,
valueField: 'Top_Id',
textField: 'Top_Name',
url: 'Tools/getTopicTypeList.ashx',
formatter: function (row) {
//console.log(row);
return "<input type=\"checkbox\" name=\"" + row.Top_Id + "\" id=\"" + row.Top_Id + "\"/>" + row.Top_Name;
},
}
}
},
{
title: '创建人',
field: 'sta_username',
width:
},
{
title: '创建时间',
field: 'top_createtime',
width:
}
]] });
}

easyui的datagrid实例实现的更多相关文章

  1. schemaeasyui实例:SSh结合Easyui实现Datagrid的分页显示

    查了好多资料,发现还是不全,干脆自己整理吧,最少保证在我的做法正确的,以免误导读者,也是给自己做个记载吧! 克日学习Easyui,发现非常好用,界面很雅观.将学习的心得在此写下,这篇博客写SSh结合E ...

  2. 实例:SSH结合Easyui实现Datagrid的批量删除功能

    在我先前的基础上面添加批量删除功能.实现的效果如下 删除成功 通常情况下删除不应该真正删除,而是应该有一个标志flag,但flag=true表示状态可见,但flag=false表示状态不可见,为删除状 ...

  3. 实例:SSH结合Easyui实现Datagrid的新增功能和Validatebox的验证功能

    在我前面一篇分页的基础上,新增了添加功能和添加过程中的Ajax与Validate的验证功能.其他的功能在后面的博客写来,如果对您有帮助,敬请关注. 先看一下实现的效果: (1)点击添加学生信息按键后跳 ...

  4. 实例:SSh结合Easyui实现Datagrid的分页显示

    近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...

  5. SSh结合Easyui实现Datagrid的分页显示

    近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...

  6. springMVC注解方式+easyUI+MYSQL配置实例

    刚接触springMVC,使用的注解方式,也在学习阶段,所以把自己学习到的记下来.本文利用springMVC从数据库读取用户信息为例,分享一下. 1.准备相关架包及资源.因为使用springMVC+e ...

  7. easyUI 中datagrid 返回列隐藏方法

    easyui的datagrid方法返回的列,有的值不需要显示可以使用hidden(属性进行隐藏) columns : [ [{ field : 'bailClass', title : '类别', w ...

  8. EasyUI 中 DataGrid 控件 列 如何绑定对象中的属性

    EasyUI 中 DataGrid 控件 是我们经常用到的控件之一, 但是 DataGrid 控件 在绑定显示列时却不支持对象属性绑定. 模型如下: public class Manager impl ...

  9. easyui的datagrid行的某一列添加链接

    通过formatter方法给easyui 的datagrid 每行增加操作链接. 效果图 jsp代码: <th field="url" width="100&quo ...

随机推荐

  1. JS魔法堂:阻止元素被选中

    一.前言 在为IE5.5~9polyfill HTML5新特性placeholder时需要阻止元素被选中,因此在网上.书上查阅相关资料,记录在此以便日后查阅. 二.IE10+实现方式──CSS3 .u ...

  2. IOS开发UI基础之UIButton

    什么是按钮?

  3. Python+Selenium进行UI自动化测试项目中,常用的小技巧1:读取excel表,转化成字典(dict)输出

    从今天开始我将会把在项目中遇到的问题,以及常用的一些技巧来分享出来,以此来促进自己的学习和提升自己:更加方便我以后的查阅. 现在要说的是:用Python来读取excel表的数据,返回字典(dict), ...

  4. mysql一个事务中有DDL语句的binlog情况

      在autocommit=1的情况下,开启一个事务,如果里面有DDL语句,那么事务开始到DDL语句之间的DML语句都会被提交.再开启新的事务.可以从binlog中看出   session语句: 09 ...

  5. 组合数学 - 波利亚定理 --- poj : 2154 Color

    Color Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7873   Accepted: 2565 Description ...

  6. UnityShader快速上手指南(三)

    简介 这一篇还是一些基本的shader操作:裁剪.透明和法向量的应用 (纠结了很久写不写这些,因为代码很简单,主要是些概念上的东西) 先来看下大概的效果图:(从左到右依次是裁剪,透明,加了法向量的透明 ...

  7. Chrome弹窗的简单应用(选择结构与循环结构)

    ★选择结构★ ★JS实现弹窗显示随机数 示例代码效果图   ★ 弹窗实现对随机数的进一步判断 示例代码效果图 ★综合应用   比较大小 ★ 判断成绩等级 ): : : : : alert(" ...

  8. Python OOP(1):从基础开始

    本文旨在Python复习和总结: 1.如何创建类和实例? # 创建类 class ClassName(object): """docstring for ClassNam ...

  9. [转]在SqlServer 中解析JSON数据

      在Sqlserver中可以直接处理Xml格式的数据,但因为项目需要所以要保存JSON格式的数据到Sqlserver中在博客:Consuming JSON Strings in SQL Server ...

  10. PHP限制HTML内容中图片必须是本站的方法

    本文实例讲述了PHP限制HTML内容中图片必须是本站的方法.分享给大家供大家参考.具体实现方法如下: 1. PHP代码如下: <?php $dom = new DOMDocument; $dom ...