问题描述:

 $("#example").dataTable( {

"bProcessing": false,

"lengthMenu": [ [4, 10, 50, -1], [4, 10, 50, "All"] ],

"bServerSide": false,

"sort": "position",

"sAjaxSource": "./PaginationServlet?custom=name",

'autoWidth': false,

"aoColumns": [

{ "mData": "name" },

{ "mData": "ParsedSet","render":simple},

{ "mData": "RetrievedSet","render":simple },

{ "mData": "checkkey","render": simple_checkbox },

{ "mData": "MissingSet","render":simple },

]

} );

} );

Here i am passing the value 'name' to the attribute 'custom'. However, i want name to be a 'variable' . So how do i pass a variable for custom.

网友答案:

You can concatenate name variable as shown below

var nameValue = 'name';

    $("#example").dataTable( {
            "bProcessing": false,
            "lengthMenu": [ [4, 10, 50, -1], [4, 10, 50, "All"] ],
            "bServerSide": false,
            "sort": "position",
            "sAjaxSource": "./PaginationServlet?custom="+nameValue,// add variable here

            'autoWidth': false,
            "aoColumns": [
                { "mData": "name" },
                { "mData": "ParsedSet","render":simple},
                { "mData": "RetrievedSet","render":simple },
                { "mData": "checkkey","render": simple_checkbox },
                { "mData": "MissingSet","render":simple },


            ]
        } );

    } );
相关阅读:
Top