Conditional Display of Dropdown in rows of datatable using jquery

Conditional Display of Dropdown in rows of datatable using jquery

guptasguptas Posts: 1Questions: 0Answers: 0

Hello,

I am using datatables for displaying the grid . The grid has a column which can have either a text value or a dropdown with values to update that column for some business condition.

Could you please help me in displaying conditional dropdown for a particular column?

The function onload calls this :
function filter(creationRange, moveRange, status) {

         var table = $('#LeadsGrid').DataTable();
         var info = table.page.info();
         var pageNumber = info.page + 1;
         existingCreationRange = $("#CreationDatePicker").val();
         existingMoveRange = $("#MoveDatePicker").val();
         existingStatus = $("#status-menu").val();

         $('#LeadsGrid').DataTable({
             searching: false,
             pageLength: 5,
             bLengthChange: false,
             destroy: true,
             //processing: true,
             //serverSide: true,
             ajax: {
                 url: "/Internet/Index",
                 type: "POST",
                 data: {
                     creationRange: creationRange,
                     moveRange: moveRange,
                     existingCreationRange: existingCreationRange,
                     existingMoveRange: existingMoveRange,
                     status: status,
                     pageNumber : pageNumber
                 }
             },
             columns: [
                 { "data": "FormattedCreationDate" },
                 { "data": "ClientFullName" },
                 { "data": "EmailAddress" },
                 { "data": "FormattedMoveDate" },
                 { "data": "DepartureCountry" },
                 { "data": "DestinationCountry" },
                 { "data": "CoordinatorFirstName" },
                 { "data": "LeadStatus" }
             ]
         });
     }

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @guptas ,

    Could you give some more information, please.

    Could you please help me in displaying conditional dropdown for a particular column?

    Where does the values for the dropdown come from? And is that just a dropdown in all cells for that column?

    It would be worth looking at columns.render - this allows you to modify the contents of a cell as it's being displayed. There are some good examples at the bottom of that page that may move you in the right direction.

    Cheers,

    Colin

This discussion has been closed.