如何更新数据库,当一行删除或添加在smartGwt ListGrid中

时间:2011-08-11 14:24:02

标签: smartgwt

    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);
    }                                                                       
}

===

public class 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 个答案:

答案 0 :(得分:1)

首先,您的ListGrid在提供的代码中没有DataSource。 ListGrid需要DataSource进行数据绑定。

从用户界面的角度来看,代码应该起作用,因为ListGrid的数据源实现了所需的操作(addfetchupdate,{{1} })。我猜你没有正确设置DataSource。