控制器

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(, ''); ;
} [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+微型持久化工具的更多相关文章

  1. EF里单个实体的增查改删以及主从表关联数据的各种增删 改查

    本文目录 EF对单个实体的增查改删 增加单个实体 查询单个实体 修改单个实体 删除单个实体 EF里主从表关联数据的各种增删改查 增加(增加从表数据.增加主从表数据) 查询(根据主表找从表数据.根据从表 ...

  2. Entity Framework Code First实体关联数据加载

    在项目过程中,两个实体数据之间在往往并非完全独立的,而是存在一定的关联关系,如一对一.一对多及多对多等关联.存在关联关系的实体,经常根据一个实体的实例来查询获取与之关联的另外实体的实例. Entity ...

  3. MagicalRecord 多表关联数据操作

    最近在使用MagicalRecord做数据持久层CoreData的操作库,今天做了一个多表关联数据的操作,整理了一个demo,特此记录一下. 关于如何使用Cocopads 和 MagicalRecor ...

  4. Contoso 大学 - 6 – 更新关联数据

    原文 Contoso 大学 - 6 – 更新关联数据 By Tom Dykstra, Tom Dykstra is a Senior Programming Writer on Microsoft's ...

  5. Contoso 大学 - 5 – 读取关联数据

    原文 Contoso 大学 - 5 – 读取关联数据 By Tom Dykstra, Tom Dykstra is a Senior Programming Writer on Microsoft's ...

  6. MYSQL中delete删除多表数据与删除关联数据

    在mysql中删除数据方法有很多种,最常用的是使用delete来删除记录,下面我来介绍delete删除单条记 录与删除多表关联数据的一些简单实例. 1.delete from t1 where 条件 ...

  7. EF学习笔记(八):更新关联数据

    学习笔记主目录链接:ASP.NET MVC5 及 EF6 学习笔记 - (目录整理) 上一篇链接:EF学习笔记(七):读取关联数据 本篇原文链接:Updating Related Data 本篇主要考 ...

  8. EF学习笔记(七):读取关联数据

    总目录:ASP.NET MVC5 及 EF6 学习笔记 - (目录整理) 本篇参考原文链接:Reading Related Data 本章主要讲述加载显示关联数据: 数据加载分为以下三种 Lazy l ...

  9. 【EF6学习笔记】(七)读取关联数据

    本篇参考原文链接:Reading Related Data 本章主要讲述加载显示关联数据: 数据加载分为以下三种 Lazy loading 这种加载方式在于需要用到这个导航属性数据的时候,才会去数据库 ...

随机推荐

  1. java 注解(自身理解)

    声明注解 使用注解 解析注解 产生的结果 注解利用的是反射机制 ============================================================= 使用注解修饰 ...

  2. next 前缀字符串

    我们在一个母字符串中查找一个子字符串有很多方法.KMP是一种最常见的改进算法,它可以在匹配过程中失配的情况下,有效地多往后面跳几个字符,加快匹配速度. 当然我们可以看到这个算法针对的是子串有对称属性, ...

  3. 无比强大!Python抓取cssmoban站点的模版并下载

    Python实现抓取http://www.cssmoban.com/cssthemes站点的模版并下载 实现代码 # -*- coding: utf-8 -*- import urlparse imp ...

  4. HTML 的超链接 a 标签中如何设置其宽度和高度?

    HTML 的超链接 a 标签中如何设置其宽度和高度? 在DIV CSS布局中,html 中 a 超链接标签,直接对其设置宽度和高度不能生效,设置宽度和高度也不起作用,这里为大家分享如何实现 a 标签宽 ...

  5. js设置加载进度提示

      CreateTime--2017年8月23日09:17:46Author:Marydon js设置加载进度提示 第一部分:CSS /*加载样式*/ .Loading { position: abs ...

  6. js 获取select的值 / js动态给select赋值

    jQuery获取Select选择的Text和Value:语法解释:1. $("#select_id").change(function(){//code...});   //为Se ...

  7. CSS3实现文字扫光效果

    本篇文章由:http://xinpure.com/css3-text-light-sweep-effect/ CSS3 实现的文字扫光效果,几乎可以和 Flash 相媲美了 效果解析 我们分析一下实现 ...

  8. python selenium --层级定位

    转自:http://www.cnblogs.com/fnng/p/3193955.html 场景: 假如两个控件,他们长的一模样,还都叫“张三”,唯一的不同是一个在北京,一个在上海,那我们就可以通过, ...

  9. jQuery源代码学习:经常使用正則表達式

    转载自:http://nuysoft.iteye.com/blog/1217898 经常使用的数字正则(严格匹配) 正则 含义 ^[1-9]\d*$ 匹配正整数 ^-[1-9]\d*$ 匹配负整数 ^ ...

  10. 저장소system.runtime.remoting.messaging.callcontext

    https://msdn.microsoft.com/ko-kr/library/system.runtime.remoting.messaging.callcontext(v=vs.110).asp ...