Attach data to server-side request #1525
-
|
I'm using Datatables server-side, and getting real-time data, I added custom date range search, and use ngModel to manage the data, but now I want to use it with all other column search. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
One way to do it would be to hitch the columns to individual variables and bind them with Example: export class SomethingComponent {
// Step 1: Setup variables to all column inputs that user can toggle.
searchDateField1 = new Date(); // or what have you
searchField2 = 'All' // you get the idea
// Step 2: Hitch the variables to AJAX call inside `dtOptions`
// inside init object
this.dtOptions = {
// blah blah
ajax: (dataTableParameters, callback) =>{
// here we go!
dataTableParameters.myData = {
searchDateField1: this.searchDateField1,
searchField2: this.searchField2
};
// HTTP POST request
this.dataService.post(dataTableParameters). subscribe ();
})
};
}Now in your server, it should be in |
Beta Was this translation helpful? Give feedback.
One way to do it would be to hitch the columns to individual variables and bind them with
ngModel. Later, in your Ajax call, add them as a property todataTableParameters.Example: