¿How i could copy text from listgrid to clipboard in SmartGWT?
Somebody told me: "Check that it does have a Datasource and if it does not, check if one should be created so that when it is run" but i don't know how.
This is a part of code:
Code:
int firstRow = cells[0][0]; for (int i = 0; i < cells.length; i++) { if (cells[i][0] != firstRow) break; fieldNames.add(locationBufferGrid.getFieldName(cells[i][1])); } TextExportSettings settings = new TextExportSettings(); settings.setFieldList(fieldNames.toArray(new String[0])); settings.setFieldSeparator("\t"); settings.setEscapingMode(EscapingMode.DOUBLE); int rowNumber = 0; Record[] selectedRecord = new Record[1]; selectedRecord[0] = locationBufferGrid.getRecord(rowNumber); DataSource dataSource = locationBufferGrid.getDataSource(); String text = dataSource.recordsAsText(selectedRecord, settings); text = text + ""; area.setValue(text); area.selectValue();
Code:
int firstRow = cells[0][0]; for (int i = 0; i < cells.length; i++) { if (cells[i][0] != firstRow) break; fieldNames.add(locationBufferGrid.getFieldName(cells[i][1])); } TextExportSettings settings = new TextExportSettings(); settings.setFieldList(fieldNames.toArray(new String[0])); settings.setFieldSeparator("\t"); settings.setEscapingMode(EscapingMode.DOUBLE); Record[] records = locationBufferGrid.getSelectedRecords(); for (int i = 0; i < records.length; i++) { int index = locationBufferGrid.getRecordIndex((ListGridRecord)records[i]); if (index >= 0) records[i] = locationBufferGrid.getEditedRecord(index); DataSource dataSource = locationBufferGrid.getDataSource(); String text = dataSource.recordsAsText(records, settings); area.setValue(text); area.selectValue();
The error in debug mode is like: Cannot read property 'recordsAsText_1_g$' of null
¿How i could fix it?
Please.
Comment