0

I am working on an asp.net mvc-5 web application and I am using entity framework +Razor view.

Currently for more than three weeks I have try and test many web grids , but I cannot find anythat provide the following main features:-

  • compatible with asp.net mvc data annotations, html helpers +model binder.
  • Provide ajax-based paging, filtering sorting
  • Provide server-side processing for the paging, filtering +sorting
  • Provide column-based filtering.

I tried many grids ; for example the Grid.MVC link provides column based filtering but it does not provide ajax-based interaction, also it does not work with mvc data annotations and html helpers. Also I tied the Lib.Web.MVC link but seems it does not provide column based filtering and it lack a sufficient documentations , however it work with data annotation and html helpers.

So my question is basically about what are the available web grids to use inside asp.net mvc, which provides the above four features.? The problem is that on the asp.net mvc books and online domination none of them use any web grids, and most of them implement functions such as paging,filtering, and sorting in a manual way such as link

Can anyone advice on this please, also does any scafilding templetes build their index views based on any grid !!?

John John
  • 1
  • 72
  • 238
  • 501

1 Answers1

1

If you would provide the input for the grid with respect of html helpers then the grid would have only common HTML fragments in every cell. In the case no column based filtering on the client side could be implemented.

Sorry, but I don't understand the last requirement "Provide column-based filtering". You have already another requirement about ajax-based paging, filtering sorting which means that the server is responsible for filtering (inclusive column-based filtering). So you can expect only that the grid send Ajax request to the server in case of the user type some value in the filter bar and press Enter or "Search".

The first requirement "compatible with asp.net mvc data annotations, html helpers +model binder" is the only requirement which free jqGrid don't satisfy. The reason of it I explained you in the discussion in comments to my previous answer on your another question: jqGrid in pure JavaScript solution. It can't have any MVC components.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • but does jqGrid provides an MVC supported version ? that the free version does not provide ?. Second question, from the previous discussion you mentioned the Lib.Web.MVC but i did not find any documentations about how to do column filtering + server-side processing using the lib.web.mvc.. can you adivce on this please ? thanks.. – John John Jan 08 '15 at 19:54
  • 1
    @johnG: Sorry, but ASP.NET MVC works **on the server side**. It can generates HTML or JavaScript code which can work on the client side, but no pure JavaScript code (like jqGrid, jQuery, ...) can execute some code on the server. JavaScript code can only *send some data* to the server and nothing more. So **only some server code** (written in C# for example and not in JavaScript) can have access too the data annotations. One can send the information to the client and some JavaScript code can generate some options of jqGrid. **All described above is not part of jqGrid**. – Oleg Jan 08 '15 at 21:28
  • 1
    @johnG: I wrote already about Lib.Web.MVC. I don't know it and can't help you. Do your hear about quantum physics? I think yes. Do you can answer me on some question from the subject of quantum physics? I think not. You can probably try to search in internet about the question and write the answer. The same for me if you ask me about `Lib.Web.MVC`. – Oleg Jan 08 '15 at 21:33
  • i know that jquery does not execute any code on the server, but i meant that i am trying to find a web grid that can handle html helpers such as html.editorfor and html.displaymessagefor which will for example display an error message if a [Required] data annotation is defined on an object property,, so that the grid will work with what asp.net mvc already provides.. – John John Jan 08 '15 at 22:02
  • 1
    @johnG: jqGrid get the data from the server via Ajax. So the initial data should be correct. The results of editing (the edited row) will be send back to the server (see [here](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#what_is_posted_to_the_server) for example the information which will be send by inline editing or [here](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#what_is_posted_to_the_server1) in case of usage form editing). **The server should validate the data and then save it in the database**. – Oleg Jan 08 '15 at 22:32
  • 1
    @johnG: The method called by `editurl` can return an error (response with some HTTP code which >=400). It can contains the error description in the body. It will inform jqGrid that the data wes not saved and the error returned from the server vill be displayed. So **your server can use data annotation to validate the data**. – Oleg Jan 08 '15 at 22:34
  • thanks for the reply, so you mean i should try jqGrid inside my asp.net mvc5 to provide server side & ajax-based paging, filtering and sorting? did you use it before ? thanks – John John Jan 09 '15 at 02:14
  • 1
    @johnG: You can easy modify the demo project from [the old answer](http://stackoverflow.com/a/5501644/315935) to be used in ASP.NET 5. The demo shows how to implement in ASP.NET MVC (using Entity Framework) server side sorting, paging and filtering/searching. I should mention that *server side paging and filtering/searching* have sense only in you need display the data with really large number of rows. If the approximately number of rows about 1000 then `loadonce: true` scenario with **client side paging/sorting/filtering** would be more quickly. The server side will be very small in the case. – Oleg Jan 09 '15 at 06:29
  • thanks for the rely, Now to be able to benefit from asp.net mvc's html helpers and data annotations and other mvc specific features, should i use the standard jqGrid or the Lib.Web.MVC ? can you adivce ? – John John Jan 09 '15 at 11:02
  • second question are you against building all the sorting and paging manually instead of using a grid ? something such as the approach mentioned on this link http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application ? – John John Jan 09 '15 at 14:59
  • 1
    @johnG: Sorry, but I can't follow you. I never wrote about "sorting and paging manually". jqGrid support `loadonce: true` option. The server should returns *all data* (just sorted) instead of returning of one page. The data will be saved as JavaScript object (the internal option `data`). jqGrid automatically changes the `datatype` to `"local"` and all sorting, filtering and paging will be done internally by jqGrid without sending any requests to the server. In case of having small number of rows the user can get response in some ms which is less then round trip to the server. – Oleg Jan 09 '15 at 17:16
  • now i got confused do u mean that i can not perform server-side processing for the paging,filtering & sorting using jqGrid? now i return back to my question is there any documentation about doing server-side & ajax-based paging,sorting& filtering using jqgrid or another grids and which satisfy my above four requirements ?.. i do not know why i am unable to reach an end point when asking a question about using grid inside an asp.net mvc5 web application? – John John Jan 09 '15 at 23:45
  • also i did not mention that you propose to manually write the sorting, paging & filtering, i just want to get your opinion if doing these functionality manually instead of using a grid is considered a bad practice ? an approach similar to this http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application – John John Jan 10 '15 at 00:35
  • @johnG: You never posted any information **how many rows** you need to display in the grid. Is it 10, 100, 1000 or 100000 or more rows? The choice will be **absolutely different**. If you search for the transport which you need to drive to your job I would recommend you to use bicycle (or to walk) in case of distance 200m, to use auto in case of 5 km and to take a train in case of 100 km or more. In the way the best solution can heavy depend on the number of rows (and columns) which you need to display. – Oleg Jan 10 '15 at 09:28
  • thanks for the reply, i do not like client side paging,filtering or sorting , becuase it will not have best network utilization and the system will be less extensible, also users might not get the latest up to date info. so i want to use server-side processing for my grid , so is this supportee by jqGrid ? and is there related documentation about this ? – John John Jan 11 '15 at 13:45
  • @johnG: Sorry, but you should answer on my questions too. **I asked you about the number of rows which you have in your project**. Server side paging is supported and documented [here](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data). I posted you already referenced with demo projects with such implementation. Independent from the question whether you or I like server/client side paging, the usage of client side paging is really **much more quickly** in case of having not so much rows (for example under 1000 rows). You can just test that. – Oleg Jan 11 '15 at 15:12
  • @johnG: I write you about client side paging only because my personal experience from one my old project. At the beginning of the project I invested my time in implementation of nice and very effective (from the point of view the server code and the database queries). After that it was published jqGrid 3.7 with `loadonce: true` feature and I tested that in my project. I was very astonished that by using `loadonce: true` one get much better performance in the project. So I rewrote (or just threw away) many parts of my code to improve the performance. So I remind the case very good. – Oleg Jan 11 '15 at 15:19