I having troubles creating column which will have different action buttons to perform editing, deleting, expanding, some other user action with record. Problem is I have already predefined DataSource in XML file connected to my DB like that:
I cannot create fake column in Datasource XML because it doesn't exist in db table. I cannot add dynamically columns to ListGrid - because there is no way. I cannot add field to DataSource object because it cannot change anything when object already created.
I even tried to do something like that (found in some sample):
But function createRecordComponent(...) never executed.
How to approach this?
Code:
<DataSource generatedBy="7.0rc2/SDK Development Only 2009-05-30" serverType="sql" dbName="MyDB" dataSourceVersion="1" tableName="PDA" ID="PDA" > <fields> <field type="text" length="8" name="ID_CODE" required="true"></field> <field primaryKey="true" type="text" length="16" name="PDA_ID" required="true"></field> <field type="text" length="35" name="ROLE_NAME" foreignKey="PDA_ROLE.ROLE_NAME" required="true"></field> <field type="number" name="STATUS" required="true" enumeration='true'></field> <field type="number" name="REFRESH_BACKGROUND" required="true" enumeration='true'></field> </fields> </DataSource>
I even tried to do something like that (found in some sample):
Code:
DataSource ds = DataSource.get("PDA"); final ListGrid listGrid = new ListGrid() { @Override protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { String fieldName = this.getFieldName(colNum); if (fieldName.equals("REFRESH_BACKGROUND")) { ImgButton chartImg = new ImgButton(); chartImg.setShowDown(false); chartImg.setShowRollOver(false); chartImg.setAlign(Alignment.CENTER); chartImg.setSrc("silk/chart_bar.png"); chartImg.setPrompt("View Chart"); chartImg.setHeight(16); chartImg.setWidth(16); chartImg.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window ww = new MapView(record.getAttribute("latitude"), record.getAttribute("logitude"), record.getAttribute("pda_id")); ww.show(); } }); return chartImg; } return null; } }; listGrid.setHeight100(); listGrid.setWidth100(); listGrid.setAutoFetchData(true); listGrid.setShowFilterEditor(true); listGrid.setCanEdit(true); listGrid.setCanRemoveRecords(true); listGrid.setAlternateRecordStyles(true); listGrid.setShowRecordComponents(true); listGrid.setShowRecordComponentsByCell(true); listGrid.setDataSource(ds);
How to approach this?
Comment