Author Topic: Empty grid, addRow function  (Read 10026 times)

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Empty grid, addRow function
« on: November 29, 2013, 07:27:45 pm »
Hello,

I am getting come over all issues one by one and now it mostly ok. But I have some couple of issue left:

1) I can add a new row grid when I hit addRow button. New row comes with json data perfectly. (CODE-1). This is possible if there is records on the gird on screen. But if grid is empty and screen shows message as (No rows to display.), and I hit addRow button, I get no error message on "Firebug console" and addRow does not work.

Could you please help to solve? Thanks


addRow function
Code: [Select]
    function addRow() {
        if (isEditing()) {
            return false;
        }
   var rowData = [];
$.ajax($.extend({}, {
dataType: "json",
    type: "POST",
    async: false
}, {
        url: "Grid.asp?isl=YeniSatir&ID=11906",
        success: function (response) {
            rowData = response;
        }
    }));

//var test1=$grid.pqGrid( "option", "dataModel.rPP" );
//$grid.pqGrid( "option", "dataModel.rPP", test1+1 );
//alert(rowData['CEKINO']);
//var rowIndxPage = $grid.pqGrid( "option", "dataModel.rowIndxPage" );
//var recIndx = $grid.pqGrid( "option", "dataModel.recIndx" );
//var numberCell = $grid.pqGrid( "option", "dataModel.numberCell" );
//alert(numberCell+'/'+rowIndxPage+'/'+recIndx);
        $grid.pqGrid("addRow", { rowIndxPage: 0, rowData:rowData});
        var $tr = $grid.pqGrid("getRow", { rowIndxPage: 0 });
        if ($tr) {
            //simulate click on edit button.
            $tr.find("button.edit_btn").click();
        }
    }

/*
,{ type: 'button', label: 'New Button',style: 'margin:0px 5px;', icon: 'ui-icon-plus', listeners: [{ click: addRow}] }
*/


dataModel
Code: [Select]
    dataModel: {
        recIndx: "ID",
        location: "remote",
        sorting: "remote",
        paging: "remote",
        dataType: "JSON",
        method: "POST",
        sortIndx: "ID",
        sortDir: "down",
colIndx:"ID",
        url: "Grid.asp?isl=Grid",
curPage: 1,
        rPP: 10,
        rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000],
        getData: function (dataJSON) {
return {curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON.data };
        }

Empty data return json ("No rows to display."  )
Code: [Select]
{}

Normal data return json
Code: [Select]
{"totalRecords":"17","curPage":"1","data":[{"ID":"74902","ORDERNO":"13WM411-P01","STYLE":"13WM411"},{"ID":......}]}

(CODE-1) new rowData return json
Code: [Select]
{
    "ORDERNO": "13WM411-P01",
    "STYLE": "13WM411",
    "SDATE": "29/11/2013",
    "SR": "1"
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Empty grid, addRow function
« Reply #1 on: December 01, 2013, 01:58:26 pm »

I'm looking into it.

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: Empty grid, addRow function
« Reply #2 on: December 02, 2013, 05:41:07 pm »
Hello ,

I want to ad done more thing to my earlier request. If grid is empty, it is also ok to get one new entery row. Is this possible?


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Empty grid, addRow function
« Reply #3 on: December 05, 2013, 07:33:00 pm »
Omer

You can test the boundary condition (i.e. when number of records is zero) by opening this url

http://paramquery.com/pro/products/clear

 which clears all the records for you for this example.

http://paramquery.com/pro/demos/editing


Please let me know whether it helped to fix your issue.

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: Empty grid, addRow function
« Reply #4 on: January 07, 2014, 03:17:56 am »
Thanks param,

Code changed. Worked
Code: [Select]
var rowData = [];
Code: [Select]
var rowData;