Dynamic Routes

Dynamic Routes

cbp8092cbp8092 Posts: 14Questions: 1Answers: 0
edited October 2013 in General
I'm trying to determine which routes to display based on a column within my datatable. How do I access that column and set that field?

Specific to my example. I want to pass in a Policy ID for a specific route and based on another column in the datatable called committed determine the routes available.

[code]
var oTable = $('#policyDataTable').dataTable({
"bServerSide": true,
"sAjaxSource": "Home/AjaxHandler",
"bProcessing": true,
"bFilter": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{
"mData": "0", //Policy ID
"bSearchable": false,
"bSortable": false,
"mRender": function (oObj) {
return getLinks(oObj);
}
}
,{
"mdata": "1",
"name": "Committed",
}
] //close ao columns
});

function getLinks(oObj) {
var test = //Access committed field

//IF committed return these links
//return 'Cancel / Endorse'

//else return these links
//return 'Review';

}
[/code]

Any help is greatly appreciated. I will continue to mess around with it.

Replies

  • cbp8092cbp8092 Posts: 14Questions: 1Answers: 0
    edited October 2013
    I got this.

    [code]
    var oTable = $('#policyDataTable').dataTable({
    "bServerSide": true,
    "sAjaxSource": "Home/AjaxHandler",
    "bProcessing": true,
    "bFilter": true,
    "bPaginate": true,
    "sPaginationType": "full_numbers",
    "aoColumns": [
    {
    "mData": "0", //Policy ID
    "bSearchable": false,
    "bSortable": false,
    "mRender": function (source, type, val) {
    return getLinks(source, type, val);
    }
    }
    ,{
    "mdata": "1",
    "name": "Committed",
    }
    ] //close ao columns
    });

    function getLinks(source, type, val) {
    var committedFlag = val[1]; //Access committed field

    if(committedFlag == "True")
    return 'Cancel / Endorse'
    else
    return 'Review';

    }
    [/code]
  • cbp8092cbp8092 Posts: 14Questions: 1Answers: 0
    "mRender": function (source, type, val)

    val - contains the position and value for each element in that row. :-)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes, the third parameter of mRender will contain the data pointed to by the mData option. That can be `null` if you wanted to have the column not relate specifically to any data in the table.

    Allan
This discussion has been closed.