how to refresh the listgird

Hi isomorphic

i am trying to refresh the list girid in every one min.

function autoRefresh()
{
alert(“enter”);
setInterval ( “refreshList”, 100000 );
}

function refreshList ( )
{
alert(“going to fecth”);
msgListDataSource.fetchData();
messageList.refreshFields();
messageList.redraw();

}

I am using Restdatasource and listgirid

These are the steps i did

  1. messageList.fetchData(); it is refreshed one time.
  2. msgListDataSource.fetchData(); it is geting data but it is nt evenRefreshing list girid with newdata.
  3. in list and datasource i am using autoFetchData: true

Please help me how to refresh list.

I think you want to be invalidating the cache and calling fetchData on the ListGrid, something like:

function refreshData(grid, criteria, callback){
    if(typeof grid != "undefined"){

        if(grid.data && grid.data.invalidateCache){
            grid.data.invalidateCache();
        }

        grid.fetchData(criteria, callback);
    }
}

If you want it to revisit the server and completely reload the ListGrid from current server data, call invalidateCache() on the listGrid. Calling fetchData() on the DataSource does not affect any databound components, it just returns data.

By the way, there are 60,000 milliseconds in a minute. :slight_smile:

Hi
Thank Q it is working fine.
But i need to refresh the gird if any change in the new data.
how i need to compare any new record in the list grid.

I am trying to find the size.

function refreshList (messageList)
{
var data=messageList.getData();
alert(“>>resultSize>”+data.resultSize);

 if(typeof messageList != "undefined"){
    
     if(messageList.data && messageList.data.invalidateCache){
        messageList.data.invalidateCache();
      }

    messageList.fetchData();
}

}

How i will get the size or length of the list grid.
i tried this also "alert(messageList.getData().getLength()); "

search for observe

Probably this is what you need:

observer.observe(messageList, "dataChanged", "refreshList()");

Hi
Thank Q for ur response. i am trying like below code .but it is nt refreshing nt even going request.

function autoRefresh123()
{

setInterval ('messageList.observe(messageList, "dataChanged", "refreshList()")',10000)
//var data=messageList.observe(messageList, "dataChanged", "observe.refreshList()");

}

function refreshList(messageList)
{

 if(typeof messageList != "undefined"){
    
     if(messageList.data && messageList.data.invalidateCache){
            messageList.data.invalidateCache();
      }
       messageList.fetchData();
    }

}
function dataChanged()
{
alert(“datchaged”);
refreshList(messageList);
}

2)i tried like this way also
setInterval (“dataChanged(messageList)”,10000)
function dataChanged(messageList)
{
alert(“datchaged”);
var data=messageList.observe(messageList, “dataChanged”, “observe.refreshList()”);
alert(data);

}
only first time i got data=true after that i am getting false only if it is true also it is nt calling refreshList()

how i will implement observe method plz can u help on this .