I am trying to save a ListGrid locally (client side) so that I can take that information from the grid and transfer it to a server script via GWT-RPC. However, I am new to SmartGWT, so I'm having difficulty figuring out the DataSource object.
Right now, I have a ListGrid set up where the majority of the cells are a combobox with three options, "TB" "IR" or "NP". The ListGrid is part of a DynamicForm. When a save Button is clicked, I call grid.saveAllEdits(); and then try to display a value from one of the rows using SC.say(). However, SC.say() always displays the default value, and I get these errors in the console.
16:31:34.057:TMR8:WARN:Log:findByKeys: dataSource 'isc_OID_28' does not have primary keys declared, can't find record
16:32:12.869:TMR2:WARN:Log:findByKeys: dataSource 'isc_OID_28' does not have primary keys declared, can't find record
16:32:12.869:TMR2:WARN:DataSource:isc_OID_28:clientOnly update operation: Unable to find record matching criteria:{monday: "TB"}
16:32:12.869:TMR2:WARN:DataSource:isc_OID_28:Empty results returned on 'update' on dataSource 'isc_OID_28', unable to update resultSet(s) on DataSource isc_OID_28. Return affected records to ensure cache consistency.
Here is the entire form. Am I going about this in the right direction or completely wrong with my approach? My ultimate goal is to get the grid cell values stored in a MySQL database, which I will need to access through GWT-RPC. I was just going to go through each record and say getAttributeAsString() and grab all the records, storing them in a POJO WeeklyReport and pass that object to server for processing.
Note: Helper functions listed in the next posting due to my post being too long.
Right now, I have a ListGrid set up where the majority of the cells are a combobox with three options, "TB" "IR" or "NP". The ListGrid is part of a DynamicForm. When a save Button is clicked, I call grid.saveAllEdits(); and then try to display a value from one of the rows using SC.say(). However, SC.say() always displays the default value, and I get these errors in the console.
16:31:34.057:TMR8:WARN:Log:findByKeys: dataSource 'isc_OID_28' does not have primary keys declared, can't find record
16:32:12.869:TMR2:WARN:Log:findByKeys: dataSource 'isc_OID_28' does not have primary keys declared, can't find record
16:32:12.869:TMR2:WARN:DataSource:isc_OID_28:clientOnly update operation: Unable to find record matching criteria:{monday: "TB"}
16:32:12.869:TMR2:WARN:DataSource:isc_OID_28:Empty results returned on 'update' on dataSource 'isc_OID_28', unable to update resultSet(s) on DataSource isc_OID_28. Return affected records to ensure cache consistency.
Here is the entire form. Am I going about this in the right direction or completely wrong with my approach? My ultimate goal is to get the grid cell values stored in a MySQL database, which I will need to access through GWT-RPC. I was just going to go through each record and say getAttributeAsString() and grab all the records, storing them in a POJO WeeklyReport and pass that object to server for processing.
Code:
public class WeeklyReportEdit extends ReportEdit {
Window popup_window;
DynamicForm form;
SectionItem tb1_section,tb2_section, tb3_section, ntb_section;
DateItem week_of;
ComboBoxItem student_name;
TextItem tb1, tb2, tb3, ntb;
ListGrid tb1_grid,tb2_grid,tb3_grid, ntb_grid;
ListGridField loc_col, mon_col,tues_col,wed_col,thurs_col,fri_col;
ButtonItem save;
ButtonItem cancel;
DataSource data_source;
public WeeklyReportEdit() {
//configure popup window
popup_window = new Window();
popup_window.setTitle("Weekly Report Form");
popup_window.setWidth(625);
popup_window.setHeight(500);
popup_window.centerInPage();
//configure form
form = new DynamicForm();
form.setWidth(600);
form.setPadding(5);
form.setNumCols(2);
form.setTitleOrientation(TitleOrientation.TOP);
//create general fields
SectionItem general_section = new SectionItem();
general_section.setDefaultValue("General");
general_section.setSectionExpanded(true);
general_section.setItemIds("student_name","week_of");
student_name = new ComboBoxItem("Student Name");
student_name.setName("student_name");
week_of = new DateItem();
week_of.setName("week_of");
week_of.setTitle("Week Of");
//create behavior text fields
SectionItem behavior_section = new SectionItem();
behavior_section.setDefaultValue("Monitored Behaviors");
behavior_section.setSectionExpanded(true);
behavior_section.setItemIds("tb1");
tb1 = new TextItem();
tb1.setName("tb1");
tb1.setTitle("Target Behavior 1");
tb1.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent e) {
tb1_section.setDefaultValue(e.getValue().toString());
}
});
// Create fields for the grids
createListGridFields();
//create tb1 grid
tb1_section = new SectionItem();
tb1_section.setDefaultValue("Target Behavior 1");
tb1_section.setItemIds("tb1_canvas");
tb1_section.setSectionExpanded(false);
createTB1Grid();
tb1_grid.setFields(loc_col,mon_col,tues_col,wed_col,thurs_col,fri_col);
CanvasItem tb1_canvas = new CanvasItem();
tb1_canvas.setCanvas(tb1_grid);
tb1_canvas.setName("tb1_canvas");
tb1_canvas.setShowTitle(false);
tb1_canvas.setColSpan(2);
//create save and cancel buttons
save = new ButtonItem("save");
save.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent e) {
tb1_grid.saveAllEdits();
ListGridRecord record = tb1_grid.getRecord(1);
SC.say(record.getAttributeAsString("monday"));
}
});
cancel = new ButtonItem("cancel","Cancel");
save.setStartRow(true);
save.setEndRow(false);
cancel.setStartRow(false);
//add all fields to the form
form.setFields(new FormItem[] {
general_section,
student_name,
week_of,
behavior_section,
tb1,
tb1_section,
tb1_canvas,
save,
cancel});
//add form to popup window
popup_window.addItem(form);
//display
popup_window.show();
}
Comment