PDA

View Full Version : Grid not moving together with GridFilters



herchenroder
22 Sep 2011, 12:04 PM
Totally stuck on this issue, hoping someone out there has seen this before...

We have a Grid<ModelData> to which we have added a GridFilters via .addPlugin

When you scroll with the scrollbars, the filter moves together with the columns of the grid.

But if you press tab while in any of the filter text boxes, and keep pressing tab to move off the screen's viewable area, the filter moves to the left while the columns do not.

We have tried trapping the tab key and setting the position of the grid but that has not proved successful.


final ListStore<ModelData> store; // Build the GXT Grid


assert loader != null : "Loader is null when rendering MultilineContainer";
store = new ListStore<ModelData>(loader);
grid = new Grid<ModelData>(store, columnModel);
grid.setStripeRows(true);
grid.addPlugin(this.filters);
grid.getView().setAutoFill(false);
grid.setColumnReordering(true);
grid.disableTextSelection(false);
grid.setSelectionModel(selectionModel);
grid.addPlugin(selectionModel);



filters is just


private GridFilters filters;

then in the constructor


this.filters = new GridFilters();

Is there any way to set the grid's positioning or to force the filter not to move when the users press tab?

We've tried


grid.getElement().getStyle().setPosition(Position.ABSOLUTE);
grid.getElement().getStyle().setPropertyPx("left", 200);


But that just moves the grid off the screen completely.

Thank you for any help you can provide.

herchenroder
9 Jan 2012, 9:43 AM
We found a workable solution for this problem, so I figured I'd post it here in case anyone else can use it.

Essentially we are leveraging the scrollIntoView method that GWT adds to the DOMImpl class.


public void alignFiltersToGrid(int colIndex){
com.google.gwt.dom.client.Element td = grid.getView().getCell(0, colIndex);
if(td != null)
td.scrollIntoView();
}


Look at the implementation of scrollIntoView and you'll see the hotness. All we have to do is send the right column index to our alignFiltersToGrid method. We set a keydown listener on each filter to decide if you should view the previous or next column (W00t event.isShiftKey!).


@Override
public void componentKeyDown(ComponentEvent event) {
switch(event.getKeyCode()){
case 9:
int colToShow = event.isShiftKey() ? colIndex-1 : colIndex+1;
listener.onAlignFiltersToGrid(colToShow);
break;
case 13:
listener.onSearchByFilters();
break;

}
}


Really the meat of the fix is grid.getView().getCell and scrollIntoView.

sharaf.satishkumar
9 Jan 2012, 10:08 PM
@ herchenroder (http://www.sencha.com/forum/member.php?283403-herchenroder) - wow..!! Thanks a lot it worked for my problem too.. :):).

my thread is.

http://www.sencha.com/forum/showthread.php?173029-Grid-not-scrolling-while-tabbing-on-the-grid-columns.

sharaf.satishkumar
10 Jan 2012, 1:24 AM
but this is not working in ie8 :(
what might be the reason for that? :((