AlexanderKrutov / DataTables.Queryable

.Net library for clever processing of requests from datatables.net jQuery plugin on the server side (ASP.NET, Nancy or any other web server).
MIT License
50 stars 19 forks source link

Add custom Data Fields to DataTablesAjaxPostModel #42

Open nchelix opened 5 years ago

nchelix commented 5 years ago

I'm having to use the DataTablesAjaxPostModel in my implementation because there are too many columns and the "GET" query is too long. However, this method does not allow for passing back custom data points in the AJAX call as can be done with the GET function. Would be nice functionality to have those included in some ways if possible.

VictorioBerra commented 5 years ago

Why cant you just make a ViewModel that wraps the PostModel? Or pass your extra stuff as query string.

public class MyCustomVM
{
    public DataTablesAjaxPostModel request { get; set; }
    // Whatever props you want for your custom stuff.
}

On Thu, Feb 7, 2019, 1:35 PM Jeremy Barnes <notifications@github.com wrote:

I'm having to use the DataTablesAjaxPostModel in my implementation because there are too many columns and the "GET" query is too long. However, this method does not allow for passing back custom data points in the AJAX call as can be done with the GET function. Would be nice functionality to have those included in some ways if possible.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AlexanderKrutov/DataTables.Queryable/issues/42, or mute the thread https://github.com/notifications/unsubscribe-auth/ACzG61jnwfNcRrVreqGhJEpDmOWR1EImks5vLH_zgaJpZM4aozte .

nchelix commented 5 years ago

I am currently working around it by using a query string for the extra stuff, however it's a bit clunky (currently using Request.Params[variable] to load it on the controller and that is working). I did attempt to build a wrapper ViewModel, and that passed back the additional custom data using the ajax: data and mapped to my additional fields, but the DataTablesAjaxPostModel in the ViewModel was coming back null so it failed. I could continue to use the query string option but was hoping as an enhancement it could be integrated into the existing DataTablesAjaxPostModel.