C# easyui datagrid 复选框填充。

具体效果如下:

首页

添加值班信息页面:

编辑 值班信息页面

控制器源码

  1  private DoctorDutyDao doctorDutyDao = new DoctorDutyDao();
  2         private TimeDao timeDao = new TimeDao();
  3
  4         //展示首页
  5         public ActionResult Index()
  6         {
  7             SetupLayoutViewData(750, 700);
  8             //查询时间表
  9             Time queryTime = new Time();
 10             if (UserContext.CurrentUser != null)
 11             {
 12                 queryTime.CompanyId = UserContext.CurrentUser.Id;
 13             }
 14             IList<Time> times = timeDao.QueryForList(queryTime);
 15             //生成JS
 16             string js = @"$(function () {";
 17             js += @"$(‘#grid‘).datagrid({";
 18             js += @"url: ‘QueryForPage‘,";
 19             js += @"singleSelect: true,";
 20             js += @"fitColumns: true,";
 21             js += @"columns: [[";
 22             js += @"{ field: ‘Id‘, title: ‘选择‘, hidden: true, width: 100, align: ‘center‘,formatter:radioFormatter },";
 23             js += @"{ field: ‘DoctorName‘, title: ‘医生名称‘, width: 100, align: ‘center‘,formatter:PageUI.RenderEditTrigger },";
 24             js += @"{ field: ‘DoctorPosition‘, title: ‘职称‘, width: 100, align: ‘center‘ },";
 25             js += @"{ field: ‘Date‘, title: ‘起始日期‘, width: 100, align: ‘center‘ },";
 26             js += @"{ field: ‘EndDate‘, title: ‘结束日期‘, width: 100, align: ‘center‘ }";
 27
 28             //循环时间表
 29             for (int i = 0; i < times.Count; i++)
 30             {                                                                         //doctorDutyCell+i 方法,是关键点,该方法内部 调用 index 母版页的 doctorDutyCell 方法
 31                 js += @",{ field: ‘Time" + (i + 1) + "‘, title: ‘" + times[i].Value + "‘, width: 100, align: ‘center‘,formatter:doctorDutyCell" + (i + 1) + " }";
 32             }
 33             js += @"   ]]";
 34             js += @" });";
 35             js += @"});;";
 36
 37             //循环时间表创建方法
 38             for (int i = 0; i < times.Count; i++)
 39             {
 40                 js += @" function doctorDutyCell" + (i + 1) + "(value, row, index) {";
 41                 js += @"return doctorDutyCell(value, row, index, ‘" + times[i].Value + "‘," + i + ");";
 42                 js += @"}";
 43             }
 44
 45
 46             ViewBag.js = js;
 47             return View();
 48         }
 49
 50         /// <summary>
 51         /// 返回数据,填充,添加页 的列表。
 52         /// </summary>
 53         /// <returns></returns>
 54         public ActionResult GetByCompany()
 55         {
 56
 57             IList<DoctorDuty> model;
 58
 59             DoctorDuty query = new DoctorDuty();
 60             long CompanyId = UserContext.CurrentUser.Id;
 61             model = doctorDutyDao.GetByCompany(CompanyId);
 62             foreach (DoctorDuty doctorDuty in model)
 63             {
 64                 doctorDuty.Date = DateTime.Now.ToString("yyyy-MM-dd");
 65                 doctorDuty.EndDate = DateTime.Now.ToString("yyyy-MM-dd");
 66
 67             }
 68             return Json(model);
 69
 70         }
 71
 72         /// <summary>
 73         /// 查询,时间 下拉框
 74         /// </summary>
 75         /// <param name="Name"></param>
 76         /// <returns></returns>
 77         public ActionResult QueryForTimeListDoctorDuty(string Name)
 78         {
 79             Time queryTime = new Time();
 80             queryTime.CompanyId = UserContext.CurrentUser.Id;
 81             IList<Time> times = timeDao.QueryForListDoctorDuty(queryTime);
 82             return Json(times);
 83         }
 84
 85
 86         /// <summary>
 87         /// 添加医生值班信息
 88         /// </summary>
 89         /// <returns></returns>
 90         public ActionResult AddIndex()
 91         {
 92             #region zhongjh 生成js
 93             //查询时间表
 94             Time queryTime = new Time();
 95             queryTime.CompanyId = UserContext.CurrentUser.Id;
 96             IList<Time> times = timeDao.QueryForList(queryTime);
 97             #region zhongjh 生成表格的js
 98             //生成JS
 99             string gridJs = @"var url = ‘@Url.Action(""GetByCompany"")‘;";
100             gridJs += @" $(‘#grid‘).datagrid({";
101             gridJs += "url:‘GetByCompany‘,";
102             gridJs += @"singleSelect: false,";
103             gridJs += @"fitColumns: true,";
104             gridJs += @"striped: true,";
105             gridJs += @"fit: true,";
106             gridJs += "columns:[[";
107             gridJs += "{field:‘Id‘,title:‘选择‘,checkbox:‘true‘,width:100,align:‘center‘},";
108             gridJs += "{field:‘DoctorName‘,title:‘医生名称‘,width:100,align:‘center‘},";
109             gridJs += "{field:‘DoctorPosition‘,title:‘职称‘,width:50,align:‘center‘},";
110             gridJs += "{field:‘Date‘,title:‘起始日期‘,width:100,formatter:setDate},";
111             gridJs += "{ field: ‘EndDate‘, title: ‘结束日期‘, width: 100, align: ‘center‘,formatter:setEndDate }";
112
113             //循环时间表
114             for (int i = 0; i < times.Count; i++)
115             {                                                 //formatter:function(value,row,index){ return ‘<input type=checkbox checked=checked id=‘+row._Id+‘_" + (i + 1) + " >‘ 方法,添加的时候,复选框都勾选
116                 gridJs += ",{ field: ‘Time" + (i + 1) + "‘, title: ‘" + times[i].Value + "‘, width: 80,formatter:function(value,row,index){ return ‘<input type=checkbox checked=checked id=‘+row._Id+‘_" + (i + 1) + " >‘;}}";
117             }
118             gridJs += ",{field:‘Remarks‘,title:‘备注‘,width:100,formatter:setRemarks}";
119
120             gridJs += "]]";
121             gridJs += "}); ";
122             ViewBag.gridJs = gridJs;
123
124
125
126
127             string gridJs3 = "";
128             //循环时间表                      var time1 = document.getElementById(n._Id + "_1").checked != false ? "9:00-11:00" : "false";
129
130             for (int i = 0; i < times.Count; i++)
131             {                                       //获取,保存的数据,因为保存的数据主要是,是否勾选复选框
132                 gridJs3 += "var time" + (i + 1) + " = document.getElementById(n._Id + \"_" + (i + 1) + "\").checked != false ? \"" + times[i].Value + "\" : \"false\";";
133
134             }
135
136             gridJs3 += " value += n._Id + \",\" + $(\"#\" + n._Id + \"_date\").val() + \",\" + $(\"#\" + n._Id + \"_Enddate\").val() + \",\" + ( ";
137
138             for (int i = 0; i < times.Count; i++)
139             {
140                 if (i == times.Count - 1)
141                 {
142                     gridJs3 += "time" + (i + 1) + ") + \",\" + encodeURI(encodeURI($(\"#\" + n._Id + \"_remarks\").val())) + \"*\";";
143                 }
144                 else
145                 {
146                     gridJs3 += "time" + (i + 1) + "+\"_\"+";
147                 }
148
149             }
150
151
152             ViewBag.gridJs3 = gridJs3;
153
154             #endregion
155
156             #region zhongjh 保存的js
157             string saveJs = "";
158             //循环时间表
159             for (int i = 0; i < times.Count; i++)
160             {
161                 saveJs += @"var time" + (i + 1) + " = $(\"#\"+n.id+\"_" + (i + 1) + "\").attr(\"checked\") != undefined?\"" + times[i].Value + "\":\"false\";";
162             }
163             string saveJsFu = "";
164             for (int i = 0; i < times.Count; i++)
165             {
166                 if (i == 0)
167                 {
168                     saveJsFu += "\"+(time" + (i + 1) + "+\"";
169                 }
170                 else if (i == times.Count - 1)
171                 {
172                     saveJsFu += "_\"+time" + (i + 1) + ")+\"";
173                 }
174                 else
175                 {
176                     saveJsFu += "_\"+time" + (i + 1) + "+\"";
177                 }
178             }
179             saveJs += "value += n.Id+\",\"+$(\"#\"+n.id+\"_date\").val()+\"," + saveJsFu + ",\"+encodeURI(encodeURI($(\"#\"+n.id+\"_remarks\").val()))+\"*\";";
180             ViewBag.saveJs = saveJs;
181             #endregion
182             #endregion
183
184             return View();
185         }
186         /// <summary>
187         /// 编辑医生值班信息
188         /// </summary>
189         /// <param name="id"></param>
190         /// <returns></returns>
191         public ActionResult Edit(long id)
192         {
193             DoctorDuty model = doctorDutyDao.GetById(id);
194             string dutyTime = model.DutyTime;
195
196             return View(model);
197         }
198
199         public ActionResult QueryForPage(string time)
200         {
201             DoctorDuty query = new DoctorDuty();
202             query.CompanyId = UserContext.CurrentUser.Id;
203
204             if (time != null && time.Trim().Length > 0)
205             {
206                 query.Date = time;
207             }
208             GenericPage<DoctorDuty> page = this.GetGenericPage();
209
210             doctorDutyDao.QueryForPage(query, page);
211
212
213
214
215             return new GenericPageResult<DoctorDuty>(page);
216         }
217
218         /// <summary>
219         /// 只用于更新
220         /// </summary>
221         /// <returns></returns>
222         public ActionResult Save()
223         {
224             DoctorDuty doctorDuty = new DoctorDuty();
225             TryUpdateModel<DoctorDuty>(doctorDuty);
226             doctorDutyDao.Update(doctorDuty);
227             return View("Edit", doctorDuty);
228         }
229
230         /// <summary>
231         /// 只用于添加
232         /// </summary>
233         /// <returns></returns>
234         public ActionResult AddSave()
235         {
236             try
237             {
238                 String value = Request.QueryString["value"].ToString();
239                 long CompanyId = UserContext.CurrentUser.Id;
240                 String[] arr = value.Split(new Char[] { ‘*‘ });  //分割勾选的每行数据
241                 foreach (String values in arr)
242                 {
243
244                     String doctorId = ""; //医生ID
245                     String date = "";     //起始日期
246                     String endDate = "";     //结束日期
247                     String dutyTime = "";  //值班时间段
248                     String remarks = "";   //备注
249
250                     String[] s = values.Split(new Char[] { ‘,‘ });
251
252
253                     doctorId = s[0];
254                     date = s[1];
255                     endDate = s[2];
256                     String[] times = s[3].Split(new Char[] { ‘_‘ }); //拼接值班时间段
257                     foreach (String time in times)
258                     {
259                         dutyTime += !time.Equals("false") ? time + "," : "";
260                     }
261                     dutyTime = !dutyTime.Equals("") ? dutyTime.Substring(0, dutyTime.Length - 1) : "";
262
263                     remarks = s.Length == 5 ? Server.UrlDecode(s[4]) : "";//解码 JavaScript encodeuri
264
265                     DoctorDuty doctorDuty = new DoctorDuty();
266                     doctorDuty.CompanyId = CompanyId;
267                     doctorDuty.Date = date;
268                     doctorDuty.EndDate = endDate;
269                     doctorDuty.DutyTime = dutyTime;
270                     doctorDuty.Remarks = remarks;
271                     doctorDuty.DoctorId = long.Parse(doctorId);
272
273                     //根据日期判断当天是否有值班记录
274                     IList<DoctorDuty> list = doctorDutyDao.getDoctorDutyBy(doctorDuty);
275                     if (list != null && list.Count != 0)
276                     {   //如果存在值班记录则删除该记录
277                         DoctorDuty doctorList1 = list[0];
278                         doctorDutyDao.Delete(doctorList1.Id);
279                         doctorDutyDao.Add(doctorDuty);
280                     }
281                     else
282                     {
283                         doctorDutyDao.Add(doctorDuty);
284                     }
285
286                 }
287                 return Json("保存成功");
288             }
289             catch (Exception exx)
290             {
291                 string a = exx.ToJson();
292                 throw;
293             }
294
295         }
296
297         public String Delete(long id)
298         {
299             doctorDutyDao.Delete(id);
300             return "success";
301         }
302
303
304
305     }
306 }

首页代码

  1 @{
  2     ViewBag.Title = "详细信息";
  3     Layout = "~/Views/Shared/_Layout.cshtml";
  4 }
  5 @section head{
  6
  7 }
  8
  9 @section toolbar{
 10         <a href="@Url.Content("~/Tooth/DoctorDuty/AddIndex")"  onclick="" class="easyui-linkbutton" data-options="iconCls:‘icon-save‘" title="添加">添加</a>
 11 }
 12
 13 @section query{
 14     <table width="100%" id="queryTable">
 15         <tr>
 16             <td>
 17                <div class="conditions">
 18                     <table border="0" cellspacing="0" cellpadding="0">
 19                         <tr>
 20                             <td class="table_left">查询日期:</td>
 21                             <td class="table_right">
 22                                 <input type="text" style="width: 130px;" class="information-input" onclick="WdatePicker()" id="time" name="time" maxlength="30" />
 23                             </td>
 24                         </tr>
 25                     </table>
 26                 </div>
 27             </td>
 28             <td class="query-conditions-row_right">
 29                 <a class="easyui-linkbutton" onclick="PageUI.OnQuery()" iconcls="icon-search">查询</a>
 30             </td>
 31         </tr>
 32     </table>
 33 }
 34
 35 <table id="grid"></table>
 36
 37 <script type="text/javascript">
 38     CreatePageUI({
 39         AddActionName: ‘@Url.Action("Add")‘,
 40          OnQuery: function () {
 41                 var time = $(‘#time‘).val();
 42                 var queryParam = {};
 43                 if (time && time.length > 0) {
 44                     queryParam.Time = time;
 45                 }
 46                 $("#grid").datagrid("load", queryParam);
 47                 this.base("OnQuery");
 48         },
 49         OnAdd: function () {
 50             this.base("OnAdd", undefined, undefined, ‘@Url.Action("Add")‘);
 51         },
 52         OnEdit: function () {
 53             var selected = $("#grid").datagrid("getSelected");
 54             if (selected) {
 55                 var parameter = { id: selected._Id };
 56                 this.base("OnEdit", parameter, ‘@Url.Action("Edit")‘);
 57             } else {
 58                 $.messager.alert("系统提示", "请选择要修改的记录!");
 59             }
 60         },
 61         OnSaveSuccess: function (data) {
 62             this.base("OnSaveSuccess", data);
 63             this.OnQuery();
 64         },
 65         OnDelete: function () {
 66             var selected = $("#grid").datagrid("getSelected");
 67             if (selected) {
 68                 $.messager.confirm("系统提示", "确定删除所选记录?", function (action) {
 69                     if (action) {
 70                         $.ajax({
 71                             url: "@Url.Action("Delete")",
 72                             type: "POST",
 73                             data: { id: selected._Id },
 74                             success: function (text) {
 75                                 if (text == "success") {
 76                                     $.messager.alert("系统提示", "删除成功!");
 77                                     $(‘#grid‘).datagrid("reload");
 78                                 } else {
 79                                     $.messager.alert("系统提示", text);
 80                                 }
 81                             },
 82                             error: function () {
 83                                 $.messager.alert("系统提示", "系统错误,删除失败!");
 84                             }
 85                         });
 86                     }
 87                 });
 88             } else {
 89                 $.messager.alert("系统提示", "请选择要删除的记录!");
 90             }
 91         },
 92         RenderEnabled: function (value,row,index) {
 93             if (value) {
 94                 return "<label style=‘color:green;‘>是</label>";
 95             }
 96             return "<label style=‘color:red;‘>否</label>";
 97         },
 98         RenderType: function (value, row, index)
 99         {
100             var val = value;
101             if (val == "1")
102                 return "<p style=‘font-family:verdana;color:red‘>文章</p>";
103             else if (val == "2")
104                 return "<p style=‘font-family:verdana;color:red‘>图文</p>";
105             else
106                 return "<p style=‘font-family:verdana;color:red‘>图片</p>";
107         },
108         OnSave: function (data) {
109             $("#DutyTime").val($("#DutyTimeCombobox").combobox("getValues"));
110             this.base("OnSave");
111
112         }
113     });
114     @Html.Raw(@ViewBag.js)
115     @*$(function () {
116         $(‘#grid‘).datagrid({
117             url: ‘@Url.Action("QueryForPage")‘,
118             singleSelect: true,
119             fitColumns: true,
120             striped: true,
121             fit: true,
122             columns: [[
123                 { field: ‘Id‘, title: ‘选择‘, hidden: true, width: 100, align: ‘center‘,formatter:radioFormatter },
124                 { field: ‘DoctorName‘, title: ‘医生名称‘, width: 100, align: ‘center‘ },
125                 { field: ‘DoctorPosition‘, title: ‘职称‘, width: 100, align: ‘center‘ },
126                 { field: ‘DepartmentName‘, title: ‘科室‘, width: 100, align: ‘center‘ },
127                 { field: ‘Date‘, title: ‘日期‘, width: 100, align: ‘center‘ },
128                 { field: ‘time1‘, title: ‘08:00 - 10:00‘, width: 100, align: ‘center‘ },
129                 { field: ‘time2‘, title: ‘10:00 - 12:00‘, width: 100, align: ‘center‘ },
130                 { field: ‘time3‘, title: ‘12:00 - 15:00‘, width: 100, align: ‘center‘ },
131                 { field: ‘time4‘, title: ‘15:00 - 18:00‘, width: 100, align: ‘center‘ },
132                 { field: ‘time5‘, title: ‘18:00 - 21:00‘, width: 100, align: ‘center‘ }
133             ]]
134         });
135     });*@
136
137
138     function radioFormatter(value, row, index) {
139         return "<label><input type=‘radio‘ name=‘gridradio‘ id=‘r_" + value + "‘ value=‘" + value + "‘/></label>";
140     }
141
142     /*
143     难点在于,数据库保存 各个时间段是用一个【DutyTime】字段存储,而前端展示的时候,要对该字段进行分割,分开展示。
144     doctorDutyCell 方法,每一次执行到Time 列都会调用到。调用的时候,
145     对查询到的数据进行分割。
146    row.DutyTime= "08:00-10:00,11:00-12:00,12:00-15:00,15:00-18:00,18:00-21:00"; 进行分割,分割之后
147     */
148     function doctorDutyCell(value, row, index, times, i) {//row 为 行数据 集合, temes 为 列名, i 表示当前为第几列。
149         var timesNumber = " ";
150         if (row.DutyTime != null) {
151             timesNumber = row.DutyTime.split(‘,‘);
152         }
153         if (timesNumber == " ") {
154             return "";
155         }
156         else
157         {
158             for (var j = 0; j < timesNumber.length; j++) {//遍历医生,值班时间,对比 列名【times】
159                 if (timesNumber[j] == times)
160                 {
161                     return ‘<input type="checkbox" checked="checked" disabled="disabled"  />‘;
162                 }
163             }
164             return ‘<input type="checkbox"  disabled="disabled" />‘;
165         }
166     }
167
168
169
170    // function checkBox(value, row, index) {
171
172    //     if (value != undefined && value != ‘‘)
173    //         return ‘<input type="checkbox" checked="checked" disabled="disabled" id="‘ + value + ‘" />‘;
174    //     else
175    //     {
176    //         return ‘<input type="checkbox"  disabled="disabled" id="‘ + value + ‘" />‘;
177    //     }
178    //}
179
180     $("#grid").datagrid({
181         onSelect: function (index, row) {
182             var keyid = row._Id;
183             $("#r_" + keyid).attr("checked", true);
184         }
185     });
186
187 </script>

添加页 代码

  1 @{
  2     ViewBag.Title = "添加信息";
  3     Layout = "~/Views/Shared/_Layout.cshtml";
  4 }
  5 @section head{
  6
  7 }
  8
  9 @section toolbar{
 10     <a class="easyui-linkbutton" id="savetip" iconcls="icon-save" onclick="PageUI.OnSave()">保存</a>
 11 }
 12
 13
 14 <table id="grid"></table>
 15 <script type="text/javascript">
 16 $(function () {
 17     @Html.Raw(@ViewBag.gridJs)//动态生成datagrid
 18     $(‘#grid‘).datagrid({
 19         onClickRow: function (rowIndex, rowData) {
 20             $("#grid").datagrid("selectRow", rowIndex);
 21         }
 22     });
 23 });
 24
 25
 26
 27 function setDate(value, row, index) {
 28     return ‘<input type="text" id="‘ + row._Id + ‘_date" style="width: 100%; text-align: center; border: 1px solid #CCC;" value="‘ + value + ‘" onClick="WdatePicker({skin:\‘whyGreen\‘,minDate:\‘%y-%M-%d\‘})" />‘;
 29 }
 30
 31 function setEndDate(value, row, index) {
 32     return ‘<input type="text" id="‘ + row._Id + ‘_Enddate" style="width: 100%; text-align: center; border: 1px solid #CCC;" value="‘ + value + ‘" onClick="WdatePicker({skin:\‘whyGreen\‘,minDate:\‘%y-%M-%d\‘})" />‘;
 33 }
 34
 35 function setRemarks(value, row, index) {
 36     return ‘<input type="text" id="‘ + row._Id + ‘_remarks" value="" style="width: 100%; text-align: center; border: 1px solid #CCC;" />‘;
 37 }
 38
 39     //查询
 40     function Retrieve() {
 41         $("#grid").datagrid("load");
 42     }
 43     function Back() {
 44         $("#grid").datagrid("load");
 45         $(‘#myWindow‘).window(‘close‘);
 46     }
 47
 48
 49     CreatePageUI({
 50         OnSave: function (data, dataFormID, saveActionName) {
 51
 52             var value = "";
 53             var rows = $(‘#grid‘).datagrid("getSelections");
 54             if (rows != null && 0 < rows.length) {
 55                 var flag = true;//定义标识,判断选择的,开始日期,结束日期,是否合法
 56                 $.each(rows, function (i, n) {
 57
 58                     @Html.Raw(@ViewBag.gridJs3)
 59                     //var time1 = document.getElementById(n._Id + "_1").checked != false ? "9:00-11:00" : "false";
 60                     //var time2 = document.getElementById(n._Id + "_2").checked != false ? "11:00-12:00" : "false";
 61                     //var time3 = document.getElementById(n._Id + "_3").checked != false ? "12:00-14:00" : "false";
 62                     //var time4 = document.getElementById(n._Id + "_4").checked != false ? "14:00-18:00" : "false";
 63                     //var time5 = document.getElementById(n._Id + "_5").checked != false ? "18:00-21:00" : "false";
 64                     //value += n._Id + "," + $("#" + n._Id + "_date").val() + "," + $("#" + n._Id + "_Enddate").val() + "," + (time1 + "_" + time2 + "_" + time3 + "_" + time4 + "_" + time5) + "," + encodeURI(encodeURI($("#" + n._Id + "_remarks").val())) + "*";
 65                     //if ($("#" + n._Id + "_date").val() == "") {
 66                     //    alert("请输入文章标题!");
 67                     //    $("#Title").focus();
 68
 69
 70                     var a = $("#" + n._Id + "_date").val();
 71
 72                     var b = $("#" + n._Id + "_Enddate").val();
 73
 74                     var arr = a.split("-");
 75                     var starttime = new Date(arr[0], arr[1], arr[2]);
 76                     var starttimes = starttime.getTime();
 77
 78                     var arrs = b.split("-");
 79                     var lktime = new Date(arrs[0], arrs[1], arrs[2]);
 80                     var lktimes = lktime.getTime();
 81
 82                     if (starttimes > lktimes) {
 83
 84                         alert(‘值班 开始日期 大于结束日期 ,请检查日期! ‘);
 85
 86                         $("#" + n._Id + "_Enddate").focus();
 87                         flag = false;
 88                         return;
 89                     }
 90
 91                 });
 92
 93                 value = value.length > 0 ? value.substring(0, value.length - 1) : "";
 94                 //Cfm("是否保存数据", save);
 95
 96                 if (flag) {//如果时间,没有出现问题,保存
 97                     $.ajax({
 98                         url: "@Url.Action("AddSave")?value=" + value,
 99                         type: "POST",
100                         dataType: "json",
101                         success: function (data) {
102                             alert(data);
103                             if (data) {
104                                 tips("系统提示", "保存成功");
105                                 window.history.back(-1);
106                                 $("#detailWindow").window("close");
107                             } else {
108                                 Error("保存失败");
109                             }
110                         },
111                         error: function (jqXHR, textStatus, error) { alert(jqXHR.responseText); layer.msg(‘保存失败!‘ + error.toString(), 1, { type: 3, shade: [0] }); },
112                         beforeSend: function () { $("#detailWindow").mask("处理中......"); },
113                         complete: function () { $("#detailWindow").unmask(); }
114                     });
115             }
116         }
117         else {
118             alert("请选择值班医生");
119         }
120
121         }
122
123     });
124
125
126
127 </script>

编辑页代码

 1 @model Business.Model.Tooth.DoctorDuty
 2 <form id="saveForm" action="@Url.Action("Save")">
 3     <table style="margin: 0 auto; padding: 0px; width: 100%; border: solid 1px #add9c0;">
 4
 5         <tr>
 6             <td class="query-conditions-row_left">姓名:</td>
 7             <td>
 8                 <input type="hidden" name="DutyTime" id="DutyTime" value="@Model.DutyTime" />
 9                 <input type="hidden" name="Id" value="@Model._Id" />
10                 <input type="hidden" name="DoctorName" value="@Model.DoctorName" />
11                 <input type="hidden" name="DoctorPosition" value="@Model.DoctorPosition" />
12
13                 @Model.DoctorName</td>
14
15         </tr>
16         <tr>
17             <td class="query-conditions-row_left">职称:</td>
18             <td>@Model.DoctorPosition</td>
19         </tr>
20
21
22         <tr>
23             <td class="query-conditions-row_left">起始日期:</td>
24             <td>
25                 <input type="text" id="Date" name="Date" style="width: 130px;" class="information-input" onClick="WdatePicker({ skin: ‘whyGreen‘, minDate: ‘%y-%M-%d‘ })" value="@Model.Date" /></td>
26         </tr>
27
28         <tr>
29             <td class="query-conditions-row_left">结束日期:</td>
30             <td>
31                 <input type="text" id="EndDate" name="EndDate" style="width: 130px;" class="information-input" onClick="WdatePicker({ skin: ‘whyGreen‘, minDate: ‘%y-%M-%d‘ })" value="@Model.EndDate"  /></td>
32         </tr>
33
34         <tr>
35             <td class="query-conditions-row_left">上班时间段:</td>
36             <td>
37                 <input class="easyui-combobox" name="DutyTimeCombobox" id="DutyTimeCombobox" style="width: 560px"
38                     data-options="url:‘@Url.Content("~/Tooth/DoctorDuty/QueryForTimeListDoctorDuty")‘,textField:‘Name‘,valueField:‘Value‘,multiple:true" value="@Model.DutyTime" />
39             </td>
40
41         </tr>
42     </table>
43 </form>
时间: 2024-10-13 23:07:06

C# easyui datagrid 复选框填充。的相关文章

EasyUI设置复选框单选操作

Html 代码: <td align="left" colspan="2">                    <input type="checkbox" name="SEX" value="0" />未知的性别                    <input type="checkbox" name="SEX" value=&

easyui格式化复选框

前端页面用的easyui,在一个datagrid数据列表中,每行数据前有个复选框,要求进入页面后,自动勾选符合条件的行数据.相对于简单模式的datagrid,这 里需要修改如下: (1) dagagrid中增加一列: <th field="ck" checkbox="true"></th> (2) 添加datagrid属性:singleSelect:false,onLoadSuccess:formatck, 其中onloadSuccess表示

easyui datagrid 通过复选框删除新追加的数据问题

之前写好的功能在保存好数据后再通过复选框删除是没有问题的,可现在想多追加几行,然后选择删除新追加的某几行或一行,通过$('#dg').datagrid('getChecked')方法返回选中行,然而返回的总是错误的,各种查找后,网上说是配置了idField的缘故,要么就不配这个属性,要么就配置正确的:如此想到,自己在追加行时是没有ID的,只有保存后才会将ID填上去,我便把那个属性去掉了,测试OK

easyui datagrid 让某行复选框置灰不能选

最近做项目需要类似如标题的效果,根据实际需求整合了一下网上的,内容如下: $('#dg').datagrid({     url:"url",     method:'post',     singleSelect: false,     collapsible: true,     autoRowHeight: 35,     fitColumns: true,     pagination: true,     rownumbers: true,     rowStyler:fun

使用Struts2和jQuery EasyUI实现简单CRUD系统(三)——复选框进行多选删除操作

继上篇的jsp,json,EasyUI的结合顺利将数据库数据转换成json格式后再EasyUI完成展示(Retrieve)之后,接下来的实现增删改功能也很顺手了. 增的功能还是一样,只不过将原本自己写的form用ejui提供form代替而已. 删改功能需要拿到具体选择行的id. <table id="dg" title="My Users" class="easyui-datagrid" style="width: 700px;

easyui 复选框 onClickRow事件与onSelect事件与onCheck事件

在项目中一直存在一个问题,一直都没发现问题的根源在哪里.在我们测试这边也是偶尔会出现.但是每次我去测试的时候也没问题.今天终于找到原因了! 在easyui中点击行和点击复选框触发的事件是不一样的! 点击行触发的事件 项目中部分代码:: onClickRow:function(index, row){ hospnewId=row.id; hosName=row.name; } 当我点击复选框的时候就不会触发这个事件,所以就得不到我想要的值. 看了一下easyui的api,发现有两个事件(可以满足我

easy ui datagrid 让某行复选框不能选中

//百度查找出来的 onLoadSuccess: function(data){//加载完毕后获取所有的checkbox遍历             if (data.rows.length > 0) {                 //循环判断操作为新增的不能选择                 for (var i = 0; i < data.rows.length; i++) {                     //根据operate让某些行不可选              

JS下拉复选框的实现

<html>   <head>     <script src="jquery-1.7.2.min.js"></script>     <script src="jquery.easyui.min.js" ></script>     <link   rel="stylesheet" href="css/themes/metro/easyui.css"

纯css3实现美化复选框和手风琴效果(详细)

关键技术点和原理: 原理就是把 checkbox或 radio 给隐藏掉   ,然后给选框 绑定一个label标签. 然后用label标签作为容器,在里面放一个:before或一个after 用before模拟选框的框,用after来模拟选框的填充 通过 .magic-checkbox:checked + label:after {/*选框被选中时 显示after填充*/ display: block; } 来确定是否选中复选框,如果checked就把after的显示. 先贴出html的代码 <