[CLOSED] live update of grid rows

  1. #1

    [CLOSED] live update of grid rows

    You guys use stock market quotes in a lot of your examples, so let's stick with that theme. Let's say I have a gridPanel loaded with 100 stock quotes. I want this grid to update in real time, so I have a task manager on the page that calls an AjaxMethod every 5 seconds. Now I don't want to refresh the entire grid, so the AjaxMethod makes a database call and gets a System.Data.DataTable that contains only the rows that have changed since the last call.

    OK, so now I'm on the server side in the middle of an AjaxMethod with a DataTable that contains rows to update. What is the best way to proceed from this point. It looks like the Store.LoadData() method may be a possibility which brings me to the following questions:


    1. The LoadData() method requires a string parameter. I have been unsuccessful in converting a DataTable to a json string with your Coolite.Ext.Web.JSON.Serialize method. Any suggestions?


    2. If the LoadData() method works, will it call the appropriate renderer functions on the grid itself?




    Thank you for any assistance you can provide!
  2. #2

    RE: [CLOSED] live update of grid rows

    Hi,

    May be it is better to call Store1.reload on client side and rebind data in OnRefreshData handler of Store. In this case grid data will be refreshed automatically
    *
  3. #3

    RE: [CLOSED] live update of grid rows

    But won't that rebind/refresh the entire grid? If I have a grid that is 50 columns wide and 100 rows deep, I don't want to rebind the entire store and grid because the data in a single cell has changed.

    I'm able to retrieve the data that needs to be updated via:
    <ext:TaskManager ID="taskManagerView" runat="server">
        <Tasks>
            <ext:Task TaskID="checkForQuotes" Interval="5000">
                <Listeners>
                    <Update Handler="Coolite.AjaxMethods.GetNewQuotes({
                        success: function(newQuotes) {
                            UpdateQuotes(newQuotes);
                        }
                    });" />
                </Listeners>
            </ext:Task>
        </Tasks>
    </ext:TaskManager>
    and I can update the store client side via:
    var UpdateQuotes = function(newQuotes) {
        if (newQuotes == undefined)
            return;
        
        var grid = Ext.getCmp('gridView');
        var store = grid.getStore();
        
        for (i = 0; i < newBids.length; i++) {
            var record = store.getById(newQuotes[i].rowId);
            record.beginEdit();
            record.set(newQuotes[i].colId, newQuotes[i].QuoteAmount);
            record.endEdit();
            record.commit();
        }                
    }
    but I can't find anything that would cause the affected rows in the grid to re-render with the new data.

  4. #4

    RE: [CLOSED] live update of grid rows

    Hi,

    Your UpdateQuotes should update and re-render data correctly. I don't see anything incorrect. Can you show full sample (or send to support at coolite dot com) ?


  5. #5

    RE: [CLOSED] live update of grid rows



    I ran into the same issue. Changing the record does not change the underlying datasource for the store. If the store rebinds during local paging or sorting, existing records are discarded and new records are created from the underlying datasource. Please correct me if I am wrong (I hope I am)...

  6. #6

    RE: [CLOSED] live update of grid rows

    Hi jchau,

    Yes, you are right, changing record doesn't affected on underlying datasource. The Store at one moment contains only one page and if change page with PagingToolbar then all changes will be lost (by default you will see warning). Underlyind datasource is handled by proxy. But proxy is using to load new data. Therefore the changes in Store never mirrored to the DataSource. You need*save/reload*data for applying changes or don't use PagingToolbar (in this case all data will be loaded to the Store)




    We discussed it with you in this thread
    http://forums.ext.net/showthread.php...1489-16-1.aspx



    In this thread you need delete record. You must do it the same thing for update record


Similar Threads

  1. Data Grid with live search example
    By extnet in forum Examples and Extras
    Replies: 2
    Last Post: Jan 02, 2013, 9:44 AM
  2. Replies: 6
    Last Post: May 23, 2012, 1:48 PM
  3. [CLOSED] How to update all updated grid info in Editable Grid?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 06, 2011, 3:56 PM
  4. Update/Insert only Modified/New Datagrid Rows
    By jocker_wow in forum 1.x Help
    Replies: 1
    Last Post: Jan 10, 2011, 4:22 PM
  5. [CLOSED] Update only dirty rows of gridpanel
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 25, 2010, 2:00 PM

Posting Permissions