在创建MVC3一个可扩展的网格 - 数据建模 [英] Creating an expandable grid in MVC3 - data modelling

查看:142
本文介绍了在创建MVC3一个可扩展的网格 - 数据建模的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创造MVC3一个可扩展的网格。这是一个后续问题这个
基本上我有一个复杂的SQL查询,我需要它来填充字段集在MVC3的网格。也网格元素必须是可扩展性和扩张应该显示更多的数据。

I am trying to create an expandable grid in MVC3. This is a follow up question to this . Basically I have a complicated sql query that I need to use to populate a set of fields in a grid in MVC3. Also the grid elements must be expandable and on expansion should show additional data.

例如
我有两个SQL查询

For example I have two sql queries

Query A
select * from large tables joined

Query B
select data from selected row in query A

查询重新presents,我应该用填充网格我的第一个查询。对电网的扩展I具有由与查询B.从A扩大行来显示附加数据
我建立与我需要我可以传递给视图网格的第一行中的所有字段的图模型

Query A represents my first query which I should use to populate the grid. On expansion of the grid I have to show the additional data by expanding the row from A with the query B. I am creating a view model with all the fields I need in the first row of the grid that I can pass to the view.

Questions:
    1.) How do I directly use sql to pass the data into the views instead of joining the models
    2.) How do I make the grid expandable to show additional data? 
    3.) How do I model my sql, do I create one query for both and then selectively show data?

警告:MVC3小白

Caveat: MVC3 noob

推荐答案

在线解答

问题:

1.) How do I directly use sql to pass the data into the views instead of joining the models

这取决于,要么你的一切传上来前,写出来的隐藏字段,或包含所有数据的隐藏JSON对象,当该领域展开,显示它。所以这就是:渲染的所有数据网格和隐藏每个项目,直到你需要它,或者动态地从一个数组加载它,当用户展开表现出来。您还可以动态地抓取所需的数据,当用户点击某行,但随后你需要显示等待图像,同时你抢阿贾克斯的数据(这将是与MVC相当容易)

This depends, either you pass in everything up front and write out hidden fields, or a hidden JSON object containing all the data and when the field is expanded, show it. so that is: Render all the data in your grid and hide each item until you need it, or dynamically load it from an array and show it when the user expands. You could also dynamically grab the required data when a user clicks on a row, but then you'd need to show a wait image while you grab the data by ajax (which would be fairly easy with mvc)

2.) How do I make the grid expandable to show additional data? 

在网上扩展HTML电网结果:)依靠表明要隐藏/显示它足够了。

Plenty of expandable html grid results on the net :) Depend show you want to hide/show it.

3.) How do I model my sql, do I create one query for both and then selectively 

这取决于上述1的方法。如果你使用AJAX,你会在同一时间返回一行。在其他情况下,您可以有两个疑问,那么你合并成两个视图模型或者你加入一个查询结果与查询B如果一个孤单映射1-1,假设不存在,但这样做两个电话。再次,这是给你。你想通过所有这些数据前面,如果用户将只能扩大两行?不太可能,在这种情况下我喜欢的Ajax方式。

This depends on the approach in 1 above. If you use ajax, you'd be returning one row at a time. In the other scenario you can have two queries you then merge into two view models or you join query A results with query b if theres a 1-1 mapping, assuming there isn't though so make two calls. Again, this is up to you. Do you want to pass all that data up front if the user will only expand two rows? not likely, in that case I like the ajax approach.

这篇关于在创建MVC3一个可扩展的网格 - 数据建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆