Re: How do I set a selected item outside of an inmethod datagrid?
If I understand your problem correctly you want to do master and detail grids. When you select an item in a master table (by means of a mouse click) you want to repopulate the details(history) table and make a selection on programmaticaly, right? I would say you first need to override onItemSelection changed to intercept selection events on your master table: @Override public void onItemSelectionChanged(IModel item, boolean newValue) { super.onItemSelectionChanged(item, newValue); if (newValue) { //selection has changed on the master table //so you have to update //the history table's datasource object updateHistoryTableDatasource(item);//you implementation goes here //mark all items in a detail table for update historyTable.markAllItemsDirty(); //refresh detail table historyTable.update(); } } And for selection of a newest item in a history I would suggest that you sort history by date that the newest item comes first and then simply select the first item in the historyTable. cheers Marcin -- View this message in context: http://www.nabble.com/How-do-I-set-a-selected-item-outside-of-an-inmethod-datagrid--tp24565364p24595335.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How do I set a selected item outside of an inmethod datagrid?
if (target != null) { /* * Reset the history data source to the item id and shift report date * for the item selected. In this case the shift report date will * always be the same so we may want to optimize that later. */ checkItemHistoryDataSource.setCheckProfileId(listItemSelected .getMatrixCheckProfile().getId()); checkItemHistoryDataSource.setShiftDate(listItemSelected .getMatrixShiftReport().getDay()); /* * We know that we want to change the history item if it currently * doesn't match the listItemSelected and that the data model will * choose the day of the one selected by the listItemSelected by * default; however, unfortunately setting it in the * checkItemHistoryDataSource doesn't refresh the selectedItem. */ if ((historyItemSelected.getId() == null) || !historyItemSelected.getMatrixCheckProfile().getId().equals( listItemSelected.getMatrixCheckProfile().getId())) { itemSelectedHistoryGrid.resetSelectedItems(); selectedItemPanel.setSelectedItem(listItemSelected); target.addComponent(itemSelectedHistoryGrid); target.addComponent(selectedItemPanel); } } } }; It took me quite a bit of time to figure this out so maybe it will save someone else some time or stimulate better ideas on how to solve such a problem. -- View this message in context: http://www.nabble.com/How-do-I-set-a-selected-item-outside-of-an-inmethod-datagrid--tp24565364p24592148.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
How do I set a selected item outside of an inmethod datagrid?
I have a table that contains history entries of an item table. Whenever I change the selection in the item table, I repopulate the history in the history table. What I would like to do is select the newest history entry in the history table by default whenever I change the selection on the item table.