关联数据和formatter问题-easyui+微型持久化工具

控制器

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> 
时间: 2024-08-30 17:11:41

关联数据和formatter问题-easyui+微型持久化工具的相关文章

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

在mysql中删除数据方法有很多种,最常用的是使用delete来删除记录,下面我来介绍delete删除单条记 录与删除多表关联数据的一些简单实例. 1.delete from t1 where 条件 2.delete t1 from t1 where 条件 3.delete t1 from t1,t2 where 条件 4.delete t1,t2 from t1,t2 where 条件 前3者是可行的,第4者不可行. 也就是简单用delete语句无法进行多表删除数据操作,不过可以建立级联删除,

MVC5+EF6--8 更新关联数据

近期学习MVC5+EF6,找到了Microsoft的原文,一个非常棒的系列,Getting Started with Entity Framework 6 Code First using MVC 5,网址:http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-appli

MVC5+EF6--7 读取关联数据

近期学习MVC5+EF6,找到了Microsoft的原文,一个非常棒的系列,Getting Started with Entity Framework 6 Code First using MVC 5,网址:http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-appli

通过rowexpander插件展现一对多关联数据

先看效果 样品和审核记录是一对多的关系,通过XTemplate来展现数据.如果后台的数据是JSON格式的,这个事情就简单了,但是如果后台的数据是XML的,并且通过Model之间的hasmany关系来配置,就复杂一些了. 解决方案: model.Sample.js Ext.define("Soims.model.Sample", {     extend: 'Ext.data.Model',     requires: ['Soims.model.SampleAudit'], // 引用

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

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 在项目过程中,两个实体数据之间在往往并非完全独立的,而是存在一定的关联关系,如一对一.一对多及多对多等关联.存在关联关系的实体,经常根据一个实体的实例来查询获取与之关联的另外实体的实例. Entity Framework常用处理数据关联加载的方

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

总目录:ASP.NET MVC5 及 EF6 学习笔记 - (目录整理) 本篇参考原文链接:Reading Related Data 本章主要讲述加载显示关联数据: 数据加载分为以下三种 Lazy loading 这种加载方式在于需要用到这个导航属性数据的时候,才会去数据库取数据,如下图,循环中,每一次都去数据库取一次数据: Eager loading 这种加载方式则是先定义好哪个导航属性数据需要一起加载(通过是.Inclue),然后在加载主数据的时候,一并把导航数据全部加载,如下图: Expl

hibernate的基础学习--多表关联数据查询

Hibernate共提供4种多表关联数据查询方式 OID数据查询+OGN数据查询方式 HQL数据查询方式 QBC数据查询方式 本地SQL查询方式(hibernate很少用) 1.OID数据查询+OGN数据查询方式 1 public class TestOID_OGN { 2 3 /** 4 * 什么时候时候什么时候发送 5 */ 6 @Test 7 public void findUser() { 8 SessionFactory sf = H3Util.getSessionFactory();

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

本文目录 EF对单个实体的增查改删 增加单个实体 查询单个实体 修改单个实体 删除单个实体 EF里主从表关联数据的各种增删改查 增加(增加从表数据.增加主从表数据) 查询(根据主表找从表数据.根据从表找主表数据) 修改(修改从表的外键) 删除(删除主从表关系.删除主表数据.删除主从表数据.修改从表数据外键) 补充内容 SaveChanges方法提交多次操作 DbSet.Add方法返回当前实体 源码和系列文章导航 注:本章节多次演示了各种删除,要重复查看效果,需要解开注释初始化数据方法. 一.EF

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

原文地址:http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application 全文目录:Contoso 大学 - 使用 EF Code First 创建 MVC 应用 在前面的课程中已经完成了 School 数据模型.在这次的课程中,将要读取和显示相关的数据,这里指的是 EF 通