I have a TreeGrid that displays data from a SQL Server view. What I’m having trouble with is making the TreeGrid update after the underlying tables are changed. I realize that in order for the update to happen I will have to notify the DataSource managing the view that there has been a change. The code below is being executed after an insert or update to the the tables that make up the view (there are two tables included in the view). Whenever the code below is executed the entire TreeGrid is emptied and the message “No items to show.” is displayed in the top center of the TreeGrid. No criteria has been set. I’m just trying to load all of the contents of the view.
Please have a look at the code below and, if you wish, please point me in the right direction. Also, if this question has already been posted or something similar to it, please link me to the relevant thread. I’ve already been searching this forum for a couple of hours. I really have tried to refrain from posting a duplicate.
public void reloadTree(DSResponse response, DSRequest request){
final DSResponse fwdResponse = new DSResponse ();
fwdResponse.setInvalidateCache (true);
Record [] records = response.getData();
Record [] newRecords = new Record[records.length];
for (int i = 0; i < records.length; i++){
Record record = records[i];
Record viewRec = new Record();
viewRec.setAttribute("ID", record.getAttributeAsInt("ID"));
viewRec.setAttribute("GROUP_ID", 0);
viewRec.setAttribute("PARENT_GROUP_ID", record.getAttributeAsInt("GROUP_ID"));
viewRec.setAttribute("DISPLAY_NAME", record.getAttribute("DISPLAY_NAME"));
viewRec.setAttribute("FILE_NAME", record.getAttribute("FILE_NAME"));
viewRec.setAttribute("PUBLISHED", record.getAttribute("PUBLISHED"));
newRecords[i] = viewRec;
}
fwdResponse.setData (newRecords);
request.setOperationType (DSOperationType.UPDATE);
DataSource.get("viewReportTree").updateCaches(fwdResponse, request);
}
Using SmartGWT Pro 2.3
GWT 2.3.0
Google Chrome 13.0.782.112 m
Mozilla Firefox 5.1
Server specs:
Ubuntu 8.04.4 LTS
JBoss Web 2.1.1.CR3
DB
SQL Server 2005