Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ¿How i could copy text from listgrid to clipboard in SmartGWT?


    ¿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();
    Or, i'm trying:

    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();
    I have the same result.
    The error in debug mode is like: Cannot read property 'recordsAsText_1_g$' of null

    ¿How i could fix it?

    Please.

    #2
    There are multiple copy samples that are working fine.

    Your error message doesn't make much sense and does not appear to be something that could result from the above code.

    Please see the FAQ - you have not included your full version, browser, and your error message is only partial - there are instructions in the FAQ and in the Debugging overview for getting a full stack trace.

    If you are trying to report a possible framework bug, please also include a complete, ready-to-run test case.

    Comment

    Working...
    X