Hi,

 

I have a couple of use cases for DataTable for which I have not been able to
find a solution. Both use cases are pretty common and I am sure that the
solution is something very simple, but somehow I am struggling to get it
working.

 

1.       How to highlight/color differently the currently 'selected' row in
the data table. I have implemented the select functionality by using the
AjaxEventBehavior as shown the snippet below.

 

dataTable = new DataTable( "dataTable", columns, employeeListDataProvider,
20) {

                                                @Override

                                                protected Item
newRowItem(String id, int index, final IModel model) {

                                                                rowItem.add(
new AjaxEventBehavior( "click") {

 
@Override

 
protected void onEvent(AjaxRequestTarget target) {

 
selectedEmployee = (Employee) model.getObject( );

 
}

                                                                } );

 

                                                                return
rowItem;

                                                }

 

                                };

The select functionality is working just fine, but now I want to show the
row corresponding to the selected employee in a different color. The
selected row should display as 'selected' even when the user navigates to
another page (page means the datatable page using paging navigator and not
WebPage) and then navigates back to the original datatable page.

 

2.       My list of employees is pretty large and I am using a
BootstrapAjaxPagingNavigator along with the datatable. Now in some cases I
want to programmatically show a particular employee as selected. So for
this, I need some means to find the datatable page number which will have
the desired employee,  I then need to programmatically display that
particular datatable page and then I need to show the row corresponding to
the desired employee as highlighted/selected. To complicate matters further,
my datatable is styled to display vertical scroll bars. So if possible,
after displaying the correct datatable page, the datatable should
automatically scroll-up or scroll-down to ensure that the row corresponding
to the desired employee, is always visible to the user.

 

Any pointers to get the above two use cases working ?

 

 

Warm regards,

 

Anup 

 



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Reply via email to