标签:
控制器
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http; using System.Web.Mvc; using NXT.Core; using NXT.Models; using System.Web.Script.Serialization; namespace NXT.Areas.Anm.Controllers { public class RemoveController : Controller { public ActionResult Index() { var code = new sys_codeService(); var model = new { dataSource = new { //penname = code.GetValueTextListByType("MeasureUnit") // penID = new bas_penService().GetDynamicList(ParamQuery.Instance() //.Select("bas_pen_id as value,pen_name as text")), penID = new bas_penService().GetDynamicList(ParamQuery.Instance() .Select("bas_pen_id as value,pen_name as text")), //unit = pens.GetModelList(""), //unit = code.GetValueTextListByType("MeasureUnit") }, urls = new{ query = "/api/Anm/Remove", newkey = "/api/Anm/Remove/getnewkey", edit = "/api/Anm/Remove/edit" }, resx = new{ noneSelect = "请先选择一条数据!", editSuccess = "保存成功!", auditSuccess = "单据已审核!" }, form = new{ RFID_id = "" , remove_reason = "" , remove_time = "" , penid = "" , pen_name = "" , removenote = "" , bas_pen_id = "" }, defaultRow = new { }, setting = new{ idField = "remove_id", postListFields = new string[] { "remove_id" ,"RFID_id" ,"remove_reason" ,"remove_time" ,"penid" ,"pen_name" ,"removenote" } } }; return View(model); } } public class RemoveApiController : ApiController { public dynamic Get(RequestWrapper query) { query.LoadSettingXmlString(@" <settings defaultOrderBy=‘remove_id‘> <select>*</select> <from>bus_remove</from> <where defaultForAll=‘true‘ defaultCp=‘equal‘ defaultIgnoreEmpty=‘true‘ > <field name=‘RFID_id‘ cp=‘equal‘></field> <field name=‘remove_reason‘ cp=‘equal‘></field> <field name=‘remove_time‘ cp=‘equal‘></field> <field name=‘penid‘ cp=‘equal‘></field> <field name=‘pen_name‘ cp=‘equal‘></field> <field name=‘removenote‘ cp=‘equal‘></field> <field name=‘remove_id‘ cp=‘equal‘></field> </where> </settings>"); var service = new bus_removeService(); var pQuery = query.ToParamQuery(); var result = service.GetDynamicListWithPaging(pQuery); return result; } public string GetNewKey() { return new bus_removeService().GetNewKey("remove_id", "maxplus").PadLeft(6, ‘0‘); ; } [System.Web.Http.HttpPost] public void Edit(dynamic data) { var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@" <settings> <table> bus_remove </table> <where> <field name=‘remove_id‘ cp=‘equal‘></field> </where> </settings>"); var service = new bus_removeService(); var result = service.Edit(null, listWrapper, data); } } }
视图层
@{ ViewBag.Title = "Remove"; Layout = "~/Views/Shared/_Layout.cshtml"; var Cols = new NXT.Models.sys_roleMenuColumnMapService().GetCurrentUserMenuColumns(); } @section scripts{ @*<script src="~/Areas/Mms/ViewModels/mms.com.js"></script>*@ <script src="/Content/js/viewModel/com.viewModel.searchEdit.js"></script> <script type="text/javascript"> using([‘datebox‘]); using([‘combobox‘]); var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model)); var viewModel = function(){ com.viewModel.searchEdit.apply(this,arguments); com.formaterpenID = utils.fnValueToText(data.dataSource.penID); } ko.bindingViewModel(new viewModel(data));//new一个viewModel,并把data传进去 </script> } @Html.RenderToolbar() <div class="container_12" style="position:relative;"> <div class="grid_1 lbl">RFID</div> <div class="grid_2 val"><input type="text" data-bind="value:form.RFID_id" class="z-txt " /></div> <div class="grid_1 lbl">变动原因</div> <div class="grid_2 val"><input type="text" data-bind="value:form.remove_reason" class="z-txt " /></div> <div class="grid_1 lbl">变动时间</div> <div class="grid_2 val"><input type="text" data-bind="dateboxValue:form.remove_time" class="z-txt easyui-datebox" /></div> <div class="clear"></div> <div class="grid_1 lbl">圈ID</div> <div class="grid_2 val"><input type="text" data-bind="value:form.penid" class="z-txt " /></div> <div class="grid_1 lbl">圈名称</div> <div class="grid_2 val"><input type="text" data-bind="datasource:dataSource.penID,comboboxValue:form.penID" class="z-txt easyui-combobox" /></div> <div class="grid_1 lbl">备注</div> <div class="grid_2 val"><input type="text" data-bind="value:form.removenote" class="z-txt " /></div> <div class="clear"></div> <div class="prefix_9" style="position:absolute;top:5px;height:0;"> <a id="a_search" href="#" class="buttonHuge button-blue" data-bind="click:searchClick" style="margin:0 15px;">查询</a> <a id="a_reset" href="#" class="buttonHuge button-blue" data-bind="click:clearClick">清空</a> </div> </div> <table data-bind="datagrid:grid" style="display:none"> <thead> <tr> <th field="remove_id" hidden="true" sortable="true" align="left" width="80" editor="text" >remove_id</th> <th field="RFID_id" sortable="true" align="left" width="80" editor="text" >RFID</th> <th field="remove_reason" sortable="true" align="left" width="80" editor="{type:‘combobox‘,options:{}}" >变动原因</th> <th field="remove_time" sortable="true" align="left" width="80" editor="datebox" formatter="com.formatDate">变动时间</th> <th field="pen_name" sortable="true" align="left" width="80">圈ID</th> <th field="penid" sortable="true" align="left" width="80" editor="{type:‘combobox‘,options:{data:data.dataSource.penID}}" formatter="com.formaterpenID">圈名称</th> <th field="removenote" sortable="true" align="left" width="180" editor="text" >备注</th> </tr> </thead> </table>
关联数据和formatter问题-easyui+微型持久化工具
标签:
原文地址:http://www.cnblogs.com/hellowzd/p/4401743.html