Author Topic: Add new record with buttons and dialog  (Read 5681 times)

forwheeler

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 26
    • View Profile
Add new record with buttons and dialog
« on: December 17, 2013, 09:21:27 pm »
While looking at the Add, Edit, Delete demo I see that in the addRow function we build a row and use data.push to add to the row collection. After doing this I don't see the new row. I commented out the refreshDataAndView but there is no difference. I assume after the push is where I need to send the new row to the server to add it to my database.

UPDATE

I now add my new row to the database after the push and then call the refreshDataAndView and the grid does not update. If I refresh the page then it updates. I can see in the json returned that the new row is there but the grid ignores it.

Code: [Select]
var row = [];
                        row[0] = $frm.find("input[name=test1]").val();
                        row[1] = $frm.find("input[name=test2]").val();
                        row[2] = $frm.find("input[name=test3]").val();
                          data.push(row);
                        jsonstring = {"Test1": row[0], "Test2": row[1], "Test3": row[2] };
                        Add(JSON.stringify(jsonstring));//call add method

                        //$grid.pqGrid("refreshDataAndView");
                        $grid.pqGrid("refresh");
« Last Edit: December 18, 2013, 12:27:56 am by forwheeler »

forwheeler

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Add new record with buttons and dialog
« Reply #1 on: December 18, 2013, 02:37:11 am »
The refreshDataAndView works in firefox but not IE10 or chrome.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Add new record with buttons and dialog
« Reply #2 on: December 18, 2013, 12:36:45 pm »
Are you using location : "local"

If you want that refreshDataAndView should fetch updated remote data, then location should be "remote" and refreshDataAndView should be called after Add(JSON.stringify(jsonstring)); returns.




« Last Edit: December 18, 2013, 04:25:05 pm by paramquery »

forwheeler

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Add new record with buttons and dialog
« Reply #3 on: December 18, 2013, 07:28:15 pm »
I am using location: remote in datamodel. I moved the $grid.pqGrid("refreshDataAndView") to the success of the ajax in the add function and it still won't refresh the data. I need to refresh the page. It works in the FF browser.

This is my datamodel

Code: [Select]
       var dataModel = {//define datamodel and get data from server
            cache: true,
            location: "remote",
            paging: "remote",
            sorting: "local",
            sortDir: "down",
            //rPP: 20,
            //rPPOptions: [10, 20, 40],
            dataType: "JSON",
            getUrl: function () {
                return { url: "/PCA/PCAData/" };
            },
            getData: function (dataJSON, textStatus, jqXHR ){
                return { data: dataJSON };
            }
        };

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Add new record with buttons and dialog
« Reply #4 on: December 18, 2013, 07:34:06 pm »
try cache: false

forwheeler

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Add new record with buttons and dialog
« Reply #5 on: December 18, 2013, 07:49:26 pm »
Yes that worked. The browsers must treat that setting differently. Thanks!