Datatables 1.10+ & ASP.NET MVC 5 with Server Side Integration
Datatables 1.10+ & ASP.NET MVC 5 with Server Side Integration
I recently had to convert a ColdFusion application to ASP.NET MVC 5 application.
As I am fairly new to ASP.NET, this post was a time saver:
https://echosteg.com/jquery-datatables-asp.net-mvc5-server-side
This project uses samples of the original code created by Marien Monnier (French to English):
https://translate.google.com/translate?sl=fr&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=https%3A%2F%2Fblog.goood.pro%2F2014%2F11%2F21%2Fmvc-utilisation-de-jquery-datatables-en-mode-serveur%2F&edit-text=
Replies
Thanks for posting this. I'm sure others will find it useful.
Regards,
Allan
@allan
I am trying to add the ability to use different data for each column type in the datatables mvc 5 code.
As outlined in
columns.data
. Use different data for the different data types requested by DataTables (_
,filter
,display
,type
orsort
).I actually have 7 columns in my table but I shortened to 2 columns for this example
Step 1 in DatatablesViewModel.cs change the
Data
property to typeobject
:to
Below you can see that
columns[0].Data (id)
is correctly set to a string value ofid
However,
columns[2].Data
(name) has a value of {object}`.I was expecting to see
Questions:
1. How do I get the _ , display, filter and sort values from the {object}?
2. Am I using the wrong type for Data (get; set; }?
3. How do I get the column.data parameter to hold a string or object value in C#?
Sorry I am new to C#.
I have created the classes that the data object set from DataTables via ajax. Hope this will save you some time and hopefully it is a good starting point for you.
https://github.com/bindrid/DataTablesServerSide
Hi, you may check this library which works on IQueryable and can be used with Entity Framework:
https://github.com/VladimirDimov/jQuery-Datatables-Server-Side-Processing