Can i cal ajax call on the columncontrol click and bind values, below code not firing ajax call

Can i cal ajax call on the columncontrol click and bind values, below code not firing ajax call

mohammadmuzzumohammadmuzzu Posts: 2Questions: 1Answers: 0
                 $('#IndustryDt').DataTable({
                    columnControl: [ 'order', [
                        { "serverSide": true,   target: 1, extend: 'searchList', ajaxOnly: true,  className: 'dtcc-row_no-top-padding',
                                           ajax: function (data, callback, settings) {
                                               debugger;
          $.ajax({
            url: '/api/GetLocationNames',
            dataType: 'json',
            success: function (json) {
              callback(json);
            }
          });
        },
                        // ajax: {
                        // url: '/api/GetLocationNames',  // your server endpoint for location filter options
                        // type: 'GET',
                        // dataType: 'json'
                        //    }
                        }]],
                  destroy: true,
                //  stateSave: true,
                 "processing": true,     // Display a 'Processing' indicator
                 "serverSide": true,     // Enable server-side processing
                 "orderMulti": false,    // For simple ordering
                 "bInfo": true,
                  searching: true,
                 "ajax": {
                     "url": "/Industry/GetIndustryData", // Your ASP.NET Core API endpoint
                     "type": "POST",
                     //"datatype": "json",
                              dataSrc: 'Data'
                 },
                 ordering: {
                   indicators: false,
                      handler: false
                 },
                 columns: [
                 { 'data': 'IndustryId', name:'IndustryId' },
                 { 'data': 'IndustryName', name: 'Industry', autoWidth: true,

                 },
                 { 'data': 'Description', name: 'Description', autoWidth: true },
                 {
                     'data': null,
                     'className': 'dt-center editor-edit',
                     'render': function (data, type, row) {
                                             return '<a onclick="editIndustryDetails(\'' + row.IndustryId + '\')" data-id="'+row.IndustryId+'"  href="#" id="editModal" ><span class="fa fa-edit"></span> </a> &nbsp;<a  href="#"  onclick="DeleteIndustryDetails(\'' + row.IndustryId + '\');"><span class="fa fa-trash"></span> </a>';
                     },
                     orderable: false,
                     width: '10%'
                 }],

             });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,256Questions: 1Answers: 10,817 Site admin
    Answer ✓

    Do you mean you want to load the options for the list when the dropdown button is clicked? At the moment that is not an option in ColumnControl I'm afraid, but it is on my list for future enhancements.

    Allan

  • mohammadmuzzumohammadmuzzu Posts: 2Questions: 1Answers: 0

    Yes, that's great future enhancements,
    Thanks in advance

Sign In or Register to comment.