How to add a column with checkbox.

How to add a column with checkbox.

drchanixdrchanix Posts: 20Questions: 0Answers: 0
edited May 2012 in General
Hi,

Could some show me how this example is created, especially on how to add the checkboxes?
http://datatables.net/release-datatables/examples/api/form.html

Here is my code:
oTable = $('#tableList').dataTable({
"bJQueryUI": true,
"bProcessing": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"sAjaxSource": "Home/GetMethod1",
"sAjaxDataProp": "",
"aoColumns": [
{ "mDataProp": "ID" },
{ "mDataProp": "FirstName" },
{ "mDataProp": "LastName" }
<----- Checkbox goes here
]
});

My html code:


User ID
First Name
Last Name
Select <----- Header for the checkbox



Any help is greatly appreciated.

Thanks.

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Just like you would got any HTML table - in this case the checkboxes are in the source.

    Allan
  • drchanixdrchanix Posts: 20Questions: 0Answers: 0
    I don't really get your point. Can you elaborate further.
    Are you saying to build my html in the controller?
    Also, I am using entity framework and mvc.

    Thanks.
  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    When you build the response for datatables one of the columns would contain the HTML for the checkbox. set your mDataProp to "checkBox" for example and then your data source would look something like this:

    [code]
    { "aaData": [
    {
    "ID": "1",
    "FirstName": "John",
    "LastName": "Smith",
    "checkBox": ""
    }
    ...
    ] }
    [/code]
This discussion has been closed.