Frage

Here is how i am implementing flexigrid

$('.mytable').flexigrid({
    url: '<c:url value="/callController"/>',
    dataType: 'json',
    colModel : [
        {display: 'ID', name : 'id', width : 40, sortable : true, align: 'right'},
        {display: 'Name', name : 'name', width : 150, sortable : true, align: 'left'},
        {display: 'Checkbox checked', name : 'checked', width : 150, sortable : false, align: 'left' }
        ],              
    sortname: "id",
    sortorder: "asc",
    usepager: true,
    title: false,
    useRp: false,
    rp: 15,
    showTableToggleBtn: false,
    showToggleBtn: false,
            singleSelect: true,
            striped: true,
    height: 200,
    width: 'auto'
});  

If you see the third column, the value for 'checked' is returning as true/false (Boolean), but i want to display it as Yes/No on the table.

Is there any way to convert this true/false value to Yes/No while rendering the table?

Platform: Java, SpringMVC, JQuery

War es hilfreich?

Lösung

You can supply a "preProcess" callback function to alter/format the data returned by the ajax call before it is displayed:

preProcess: function(data) {
    $.each(data.rows, function(i, row) {
        row.checked = row.checked ? 'Yes' : 'No';
    });
    return data;
},

Demo on JSFiddle


Note: I don't really see where the "preProcess" callback is documented other than the following note on the Flexigrid project page:

New preProcess API, allows you to modify or process data sent by server before passing it to Flexigrid, allowing you to use your own JSON format for example.

It seems, however, to work pretty much like the "dataFilter" callback of the jQuery .ajax function.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top