tags:

views:

27

answers:

0

Hello... i am using jqgrid to display the table.... But problem is if i get json object as null, still it renders the table with the previous data. It doesnot show a blank table.

$("#order-list-table").jqGrid({
    altRows: true,
    autowidth: true,
    datatype :'json',
    url: 'order-list.htm',
    height: '90%',
    width: '100%',
    mtype: 'POST',
    colNames: [jQuery.i18n.prop('columnExternalOrderID'),
        jQuery.i18n.prop('columnInternalOrderID'),
        jQuery.i18n.prop('columnState'),
        jQuery.i18n.prop('columnDate'),
        jQuery.i18n.prop('columnErrorState'),
        jQuery.i18n.prop('columnAction'),
    ],
    colModel : [ {
            name: "Ext Order ID",
            index : "externalOrderId",
            jsonmap: "cell.0"
        }, {
            name : "Int Order ID",
            index : "Id",
            jsonmap: "cell.1"
        }, {
            name : "State",
            index : "ORD_TK_ORDER_STATE_ID",
            jsonmap: "cell.2"
        }, {
            name : "Date",
            index : "timestampOrderentry",
            jsonmap: "cell.3"
        }, {
            name : "Error State",
            index : "ORD_TK_ERROR_STATE_ID",
            jsonmap: "cell.4"
        }, {
            name : "Action",
            index : "realty",
            jsonmap: "cell.5"
        }
        ],
        postData: {"selectedOrderID" : function() {
                var sel = selID;
                selID = "";
                return sel;
            }},
        forceFit: true,
        pager: '#order-list-pager',
        rowNum:10,
        sortname : "Id",
        sortorder: "asc",
        shrinkToFit: true,
        viewrecords: true,
        jsonReader : {
            repeatitems : false
        },
        onSelectRow: function(){
            var selectOrderID = jQuery("#order-list-table").getGridParam('selrow');
            selID = selectOrderID;
            alert(selID);
            //$('#order-list-table').setGridParam(
            //            { postData: {"selectOrderID": selOrdID} });
            $('#selectOrdID').val(selectOrderID);
        },

        gridComplete: function() {
            // resize the datagrid to fit the page properly:
            var rowid = $('#selectOrdID').val();

            $('#order-list').width('100%');
            $('#order-list').css('overflow','hidden');

            $('#order-list').children('div').width('100%');

            $('#order-list').children('div').each(function() {
                    $("div", this).width('100%');
                $("table", this).width('100%');

                $("div", this).css('overflow','hidden');
                $("table", this).css('overflow','hidden');

                $("td", this).css('text-align','center');

                $(this).find('#order-list-table').width('100%');
                $(this).find('#order-list-pager').width('100%');
            });
        }
    });

here is my jqgrid call....