how to use checkbox

how to use checkbox

elifayseelifayse Posts: 3Questions: 1Answers: 0

hi all, I am very new to jquery datatables. I looked at the forum and google but can't find a solution for my problem.

I need a table with 2 columns. First column is just checkboxes, other one is just customer name.

When page is loaded, list of customer names supposed to come from mvc action result. Depends on whichever row is selected then these selected values should be send to another mvc action result. can someone help me please? how we define columns , checkboxes, customer names collection based on selected checkbox values..

Answers

  • gyrocodegyrocode Posts: 126Questions: 6Answers: 30

    See jQuery DataTables Checkboxes plug-in for simple solution of using checkboxes with jQuery DataTables.


    See more articles about jQuery DataTables on gyrocode.com.

  • elifayseelifayse Posts: 3Questions: 1Answers: 0

    thank you. this link looks great however, when you try to get data, it says do this:

    'ajax': '/lab/jquery-datatables-checkboxes/ids-arrays.txt',

    whereas in my scenario, I need to get the data from model

    ajax: {
    get: @Model.UnselectedUsers
    }

    but this doesn't work. Do you know how I can get data from Model? @Model.UnselectedUsers returns collection of users

  • elifayseelifayse Posts: 3Questions: 1Answers: 0

    I have data in @Model.UnselectedUsers

    I need to Get this data into DataTable.

        var table = $('#userTable').DataTable({
            //'ajax' : Model.UnselectedUsers.ToArray().ToJson(),
            //'ajax': { data: model},
            //'ajax': {
            //     "dataSrc": model
            //}
            @*'ajax' : ({
                type: "GET",
                url: "@Url.Action("GetSelectedUsers", "User")",
                dataType: 'json',
                data: {
                    id:  "@Model.ID"
                },
                success: function (data) {
                    //table.clear();
                    //table.rows.add(data);
                    //table.columns.adjust();
                    //table.draw();
    
                    response(data);
                }
            }),
    

    none of the ajax calls not working. I can't get the data returned from @Model.UnselectedUsers. Please help!!

This discussion has been closed.