2011-08-11 42 views
3
i want to delete the row from the grid...and changes should reflect 
    into my database..Please provide me some idea to do that... 

The above code was later updated by me and i already added the data source in which i am initializing the fields. Updated code as follws 
listgrid = new SigmaListGrid(); 
listgrid.setDataSource(screenDS); 
return listgrid;                          public 
SigmaListGrid() { 
     setShowFilterEditor(true); 
     setHeight100(); 
     setWidth100(); 
     setShowRecordComponents(true); 
     setShowRecordComponentsByCell(true); 
     setCanRemoveRecords(true); 
     setShowAllRecords(true); 
     setCanResizeFields(true); 
     setCanEdit(true); 
     setAutoSaveEdits(false); 
    }                  
} 

===如何更新數據庫,當行刪除或添加在SmartGWT的ListGrid

公共類ScreenDataSource擴展TPDDataSource {

/** 
* @param id 
*/ 
public ScreenDataSource(String id) { 
    super(id); 
    initializeFields(); 
} 

private void initializeFields() { 

    DataSourceField pkField = new DataSourceIntegerField(... 
    DataSourceField screenName = new DataSourceTextField(.....); 
    screenName.setCanEdit(true); 

    setFields(pkField, screenName; 
} 

@Override 
public void clearData() { 
    // TODO Auto-generated method stub 

} 
/** 
* This method will populate the data 
* @param records 
*/ 
public void setData(List<ScreenGridRecord> records) { 
    clearData(); 
    for (ScreenGridRecord screenGridRecord : records) { 
     addData(screenGridRecord); 
    } 
} 


@Override 
public void setData() { 

} 

}

Thanks @kimi ,i am adding a new row in list 
grid by listgrid.startEditingNew(); in newly added row i am inserting new data.Now i want to save the data @ server side .I also used listgrid.saveAllEdits(); but it is not working .    

回答

1

第一總之,您的ListGrid在提供的代碼中沒有DataSource。 ListGrid需要一個DataSource進行數據綁定。

從用戶界面點的觀點,即代碼應該是功能性的,因爲你的ListGrid的數據源實現了所需的操作(addfetchupdateremove)。我猜你沒有正確設置DataSource。

+0

上面的代碼,後來被我更新,我已經加入其中我正在初始化字段中的數據源。更新後的代碼如下:listgrid = new SigmaListGrid(); \t \t listgrid.setDataSource(screenDS); \t \t return listgrid; – Dhruva

+0

我已經更新了代碼,所以請告訴我@kimi。怎麼辦? – Dhruva

+0

如果您使用傳統的GWT服務,也最好先看看GWT-RPC數據源(http://forums.smartclient.com/showthread.php?t=4814)。只需在服務器端進行數據庫操作即可。例如。在你的服務的addMyObject(Object obj)方法中。 – levivanzele

相關問題