简体   繁体   English

在ASP.NET MVC中创建搜索界面-C#

[英]Creating a Search interface in ASP.NET MVC - C#

替代文字

The above is concept of a search interface I want to build in ASP.net MVC. 以上是我要在ASP.net MVC中构建的搜索界面的概念。 when user clicks on the '+' button, it should create a row text filters or date filters. 当用户单击“ +”按钮时,应创建一个行文本过滤器或日期过滤器。 Does jQuery offer me this flexibility or are there any such UI frameworks which would help me achieve this? jQuery是否为我提供了这种灵活性,或者是否有任何这样的UI框架可以帮助我实现这一目标? There is a search button, not shown, which when clicked should post back and obtain results and display the results 有一个搜索按钮(未显示),单击该按钮应回发并获取结果并显示结果

It sounds like you want to create dynamic form. 听起来您想创建动态表单。 Just use the Jquery .append to add new elements to your form. 只需使用Jquery .append将新元素添加到表单即可。

$("#myform").append("<input type='text' name='textfield'>")

A little difficult to visualise what you are talking about as it doesn't show in the question. 很难想象您在说什么,因为问题并未显示出来。

But if I understand your question then you want to click on a button and show some filter fields right? 但是,如果我理解您的问题,那么您想单击一个按钮并显示一些过滤器字段,对吗?

This is do-able not only in jQuery but in just standard javascript. 这不仅在jQuery中而且在标准javascript中都是可行的。 All you need to do is unhide the filter elements. 您需要做的就是取消隐藏过滤器元素。

jQuery will give you a nice way to scroll it open though and then you could do a partial post back and just return the results or partial view. jQuery将为您提供一种很好的滚动浏览方式,然后您可以进行部分回发并仅返回结果或部分视图。

$("#divFilters").slideDown(300);

The code above will open your div. 上面的代码将打开您的div。

Or you could jQuery a partial postback, return RenderPartial from your controller and replace the html in a div somewhere. 或者,您可以jQuery进行部分回发,从控制器返回RenderPartial并替换div中某个位置的html。 The RenderPartail would be a partial view with your filters in it. RenderPartail将是其中包含过滤器的局部视图。 Easier to extend at a later date too I'd have thought. 我也想过以后更容易扩展。

Is this what you were after? 这是你所追求的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM