I have a cellTable that has many columns like the followings:
OrderID - OrderDate - OrderTime - Name ..... 1 - 2012-01-05 - 11:12:12 - Tom......
Each column will have a checkBox for Hide/Unhide column:
[x] orderID (CheckBox) [x] orderDate (CheckBox) [x] orderTime (CheckBox) ......
Requirement: I want that when users uncheck the CheckBox the corresponding column will disappear & when they check the CheckBox, the column will appear in the CORRECT ORDER as at the beginning. This is the code:
public void insertColumn(int beforeIndex, TextColumn<String[]> textColumn, String columnName){ if(getView().getOrderListCellTable().getColumnIndex(textColumn)==-1){ getView().getOrderListCellTable().insertColumn(beforeIndex,textColumn, columnName); textColumn.setSortable(true); } } public void removeColumn(TextColumn<String[]> textColumn){ int index= getView().getOrderListCellTable().getColumnIndex(textColumn); if(index!=-1){ getView().getOrderListCellTable().removeColumn(index); } } However, I got this issue, when I hide / unhinde just 1 column then the order is OK, ex, hide orderDate column then the table will be like this:
OrderID - OrderTime - Name ..... 1 - 11:12:12 - Tom......
And ofcourse, when unhiding orderDate then it will go back to the beginning correctly.
Code to insert/remove orderDate
getView().getOrderDateCheckBox().addClickHandler(new ClickHandler(){ @Override public void onClick(ClickEvent event) { if(getView().getOrderDateCheckBox().getValue()){ insertColumn(1, orderDateColumn,"Order Date"); } else{ removeColumn(orderDateColumn); } } }); But if I hide both orderID & OrderDate & then unhide orderDate then it will be like this:
OrderTime - OrderDate - Name ..... 11:12:12 - 2012-01-05 - Tom......
This is not right cos he orderDate should be stand before orderTime. This cos I insertColumn(1, orderDateColumn,"Order Date"); at position 1 (before index).
Can you figure out a logic to fix this issue?
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment