showing conditional image on server side MVC setup

showing conditional image on server side MVC setup

bruceiowbruceiow Posts: 4Questions: 1Answers: 0
edited October 2013 in General
Hi guys,

I have built a datatable, powered by server side data via the ajax handler and it is wonderful.

Now it is up and running I need to extend it to requirements of my customer. Basically I need to take the value of one of the fields and show one of two images depending on the value supplied..

this is my code:
[code]
$(document).ready(function() {
$('#myTable').dataTable({
"bServerSide": true,
"sAjaxSource": "AjaxHandler",
"bProcessing": true,
"bPaginate": true,
"aoColumns": [
{ "sName": "Title" },
{ "sName": "Forename" },
{ "sName": "Surname" },
{ "sName": "Number" },
{ "sName": "DefaultCC" },
{ "sName": "TTPassed" },
{ "sName": "AppReceived" },
{ "sName": "UserValid" },
{ "sName": "CountRoles" },
{ "sName": "CountPeople" },
{
"sName": "id",
"bSearchable": true,
"bSortable": true,
"fnRender": function(oObj) {
return 'Details';
}
}
]
});
}); [/code]

What I need to do is this: if CountRoles = 1 then show image tick.png. or if CountRoles = 0 then show image cross.png. (the images need to show in the td where CountRoles is currently appearing.

Is there a way of substituting the value supplied conditionally to an image, or do I need to roll a bit of jquery externally to the table to do this form me?

many thanks

Replies

  • bruceiowbruceiow Posts: 4Questions: 1Answers: 0
    just to say, I have resovled this using customFnRowCallback in the following way:

    In my table definition jquery:

    [code] "fnRowCallback": customFnRowCallback, [/code]

    Then a jquery function:


    [code] function customFnRowCallback(nRow, aData, iDisplayIndex) {
    if (aData[8] > 0) {
    $('td:eq(8)', nRow).html('');
    } else
    {
    $('td:eq(8)', nRow).html('');
    } [/code]
This discussion has been closed.