简体   繁体   中英

make the gwt celltable row selected

I have a cell Table in GWT with columns , there are 3 rows in each column, I want the first row to get selected by default when the application starts

some thing like this

                 mycelltable.setselectedrow(index);

is it possible ?

Thanks

her is the code

                      display.getShortListedCVsBasedOnJob().getResumeDescriptionColumn().setFieldUpdater(

            new FieldUpdater<CandidateSummary, String>() {
                public void update(int index, CandidateSummary object,
                        String value) {

                    fetchResume(cvSelected, shortListedFlag);
                }
            });

This fetchResume() method calls but only when i select cell of this column , I want to call this fetchResume() method as my application starts, ie i want to make the 1st cell of the column to be selected byDefault.

Selection is handled by a SelectionModel , based on objects (not indices); so you have to select the first object from your data in the SelectionModel used by the CellTable (have a look at the Using a key provider to track objects as they change sample code in the Celltable javadoc for an example (last sample before nested classes summary ).

This could work?

setSelected(Element elem, boolean selected) 

see GWT Documentation

CellTable Google Web Toolkit

Hmm I dont see what´s the Celltable is there. I would set the initial Value like this:

int INITAL_SET_ROW = 0;
TableRowElement initalSetElement = yourCellTable.getRowElement(INITAL_SET_ROW);
yourCellTable.setSelected(initialSetElement, true);

You can try to implement it in you´re main Method. Haven´t tested it tho, hope it helps.

Simply;

List<RowType> source = new LinkedList<RowType>(); 
//put some data to this list
//populate the table
table.setRowCount(source.size(), true);
table.setRowData(0, source);
//for example, you can select the first row
RowType firstRow = source.get(0);
selectionModel.setSelected(firstRow, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM