unable to receive additional parameters in IDataTablesRequest from jquery datatable client side

unable to receive additional parameters in IDataTablesRequest from jquery datatable client side

jazzjazz Posts: 1Questions: 1Answers: 0

this is my datatable on client side no matter what i do i am unable to receive parameters passed from client side in additional parameters of iDatatablerequest. i need to do it via formbody as in future i need to create an api for this datatable too so i want to keep same code as much as possible

var headers = {};
    var token = $('input[name="__RequestVerificationToken"]').val();
    headers['__RequestVerificationToken'] = token;
        tblStudent = $("#tblStudent").DataTable({
            //responsive: true,
            autoWidth: false,
            ajax: {
                url: '/controller/method',
               
                type: "POST",
                headers: headers,

                async: true,
                data: function (d) {
                    d.appJson = JSON.stringify({
                        someNumber: 123,
                        someString: "hello",
                        someNumbers: [1, 2, 3]
                    });
                }
               
            },
            conditionalPaging: true,
            bServerSide: true,
            pagingType: "numbers",
            info: false,
            bProcessing: true,
            bSearchable: true,
            order: [
                [3, "desc"]
            ],
            language: {
                emptyTable: "No record found."
            },
            columns: [{
                className: 'details-control',
                orderable: false,
                data: "",
                searchable: false,
                defaultContent: ''
            }, 
            {
                data: "fullRollNo",
                name: "fullRollNo",
                title: 'Roll Number',
                class: "text-left pl-3 align-middle  all"
            },
            {
                data: "fullName",
                name: "fullName",
                title: 'Name',
                class: "text-left pl-3 align-middle  all"
            },
            {
                data: "enrollmentStatus",
                name: "enrollmentStatus",
                title: 'Status',
                searchable: false,
                orderable: false,
                class: "all",
                render: function (data, type, row, meta) {

                    if (type == 'display') {
                        //alert(data);
                        let labelData = data ? data : '';

                        return `<span class="label ${'stats'[labelData]} label-inline font-weight-bold label-lg">${labelData}</span>`;
                    } else
                        return data;
                },
            },

            {
                data: "gender",
                name: "gender",
                title: 'Gneder',
                searchable: false,
                class: "text-left pl-3 align-middle all",
            },

            ],
            fnRowCallback: function (nRow, aData, iDisplayIndex) {
                //alert("line 495 fnRowCallback");
                $(nRow).data("rowId", aData.Id);
                $("td:nth-child(2)", nRow).html(iDisplayIndex + 1);
                return nRow;
            },
            //"drawCallback": function(settings) {
            //    $("input[data-bootstrap-switch]").each(function() {
            //        $(this).bootstrapSwitch({ 'state': $(this).prop('checked'), disabled: true });
            //    });
            //},
            initComplete: function (settings, json) {

            }
        });
and this is server side in which i am able to receive everything like search value sort col etc but Additional Parameters always gets null

 public async Task<JsonResult> GetStudents([FromBody] IDataTablesRequest request)
    {
        var identity = (ClaimsIdentity)User.Identity;
        long.TryParse(identity.FindFirst(ClaimsConstants.ID).Value, out long ID);
        // Nothing important here. Just creates some mock data.
        var data = await Task.FromResult(_stdDbContext.table.Where(x => x.ID== ID).ToList()).ConfigureAwait(false);

       
        var filteredData = data.Where(_item => (_item.FullName.ToLowerInvariant().Contains(request.Search.Value.ToLowerInvariant())) || ((_item.FullRollNo != null) && (_item.FullRollNo.ToLowerInvariant().Contains(request.Search.Value.ToLowerInvariant()))));
       
        var dataPage = filteredData.Skip(request.Start).Take(request.Length);

        
        var response = DataTablesResponse.Create(request, data.Count(), filteredData.Count(), dataPage);

       
        return new DataTablesJsonResult(response);

    }
This discussion has been closed.