Row Filter [message #921991] |
Mon, 24 September 2012 16:22 |
dhruba kumar Messages: 51 Registered: September 2012 |
Member |
|
|
Hi I ve two nattable and they are just positioned adjacent to each other.
Table "A" has following fields:
itemnumber,val1,val2 and val3
Table "B" has following fields:
val4,val5, and val6.
the columns of table "A"(itemnumber,val1,val2 and val3) and columns of table "B"(val4,val5, and val6) makes a complete row , i.e the complete row cosists of itemnumber,val1,val2 ,val3,val4 ,val5 and val6.
Now when I filter rows of Table "A" with itemnumber,matched rows of Table "A" is filtered and shown correctly,but I want withthe matched rows of table "A" the corresponding rows of table "B" also shown to show the complete row ,i.e itemnumber,val1,val2 ,val3,val4 ,val5 and val6.
Image is attached.
Please guide.
[Updated on: Mon, 24 September 2012 16:24] Report message to a moderator
|
|
|
|
Re: Row Filter [message #922681 is a reply to message #922623] |
Tue, 25 September 2012 08:21 |
dhruba kumar Messages: 51 Registered: September 2012 |
Member |
|
|
Hi ,
columns of both tables creates a complete row and both tables have same no of rows. During filter is it possible to show only those row numbers of table "B" whose row numbers matches(or equal) to row numbers are shown in table "A".
Or u can pls tell the java file name(s) which acctually filter the data and in the table ,that will be also helpful.
[Updated on: Tue, 25 September 2012 08:26] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: Row Filter [message #924806 is a reply to message #923914] |
Thu, 27 September 2012 06:24 |
dhruba kumar Messages: 51 Registered: September 2012 |
Member |
|
|
I am currently working in with a editor ,which consist of two nattables(I am very new to nattable and its compelling features attracted me) and they are positioned adjacent to each other and they behaves as if it is a BIG single table.
The left table(or Left Pane of the Big Single table) Consists of rowid(unique) ,column LA,Column LB ,Column LC ..etc and the right table (or Right Pane of the Big Single table) Consists of rowid(unique) ,column RA,Column RB , Column RC ...etc. This BIG table should process 100 columns and 100000 rows. Now the key features of table is:
1.FULLRow Selection:When any cell/row of a table selected ,the same row of another table is also selected and this selection gives feel of a full single row selection of the BIG table.
2.SCROLL:When we scroll the vertical scrollbar of a table ,the vertical scrollbar of another table is also scrolled automatically and it is synchronised .
3.FILTERING:If I filter left table ,the right table also be filterd based on filterlist of Left Table . The vice versa should happen also.
Now I am giving code snipplets of the above requirements(I ve used Nattable Builder for its relatively easy configuration):
1.FULLRow Selection:
//When a cell in left table is selected ,the full row of the left table and right table is also selected
leftnatTable.addLayerListener(new ILayerListener() {
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellSelectionEvent) {
CellSelectionEvent cellEvent = (CellSelectionEvent) event;
SelectionLayer selectionlayer=rightbuilder.getBodyLayerStack().getSelectionLayer();
PositionCoordinate[] selectedCells =cellEvent.getSelectionLayer().getSelectedCellPositions();
PositionCoordinate[] selectedCells1=null;
SelectionLayer sellayer=rightbuilder.getBodyLayerStack().getSelectionLayer();
try{
if(sellayer!=null)
selectedCells1=sellayer.getSelectedCellPositions();
}
catch(Exception e)
{
}
if(selectedCells!=null&&selectedCells.length>0&&selectionlayer!=null)
{
if(selectedCells1==null ||selectedCells1.length<=0)
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, true);
}
else if(selectedCells[0].getRowPosition()!=selectedCells1[0].getRowPosition())
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, true);
}
}
}
}
});
//When a row in left table is selected ,the full row of the right table is also selected
leftnatTable.addLayerListener(new ILayerListener(){
public void handleLayerEvent(ILayerEvent event) {
if(event instanceof RowSelectionEvent){
RowSelectionEvent rowEvent = (RowSelectionEvent) event;
SelectionLayer selectionlayer=rightbuilder.getBodyLayerStack().getSelectionLayer();
PositionCoordinate[] selectedCells =rowEvent.getSelectionLayer().getSelectedCellPositions();
PositionCoordinate[] selectedCells1=rightbuilder.getBodyLayerStack().getSelectionLayer().getSelectedCellPositions();
if(selectedCells!=null&&selectedCells.length>0&&selectionlayer!=null)
{
if(selectedCells1==null ||selectedCells1.length<=0)
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, false);
}
else if(selectedCells[0].getRowPosition()!=selectedCells1[0].getRowPosition())
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, false);
}
}
}
}
});
//When a cell in right table is selected ,the full row of the right table and left table is also selected
rightnatTable.addLayerListener(new ILayerListener() {
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellSelectionEvent) {
CellSelectionEvent cellEvent = (CellSelectionEvent) event;
SelectionLayer selectionlayer=leftbuilder.getBodyLayerStack().getSelectionLayer();
PositionCoordinate[] selectedCells =cellEvent.getSelectionLayer().getSelectedCellPositions();
PositionCoordinate[] selectedCells1=null;
SelectionLayer sellayer=leftbuilder.getBodyLayerStack().getSelectionLayer();
try{
if(sellayer!=null)
selectedCells1=sellayer.getSelectedCellPositions();
}
catch(Exception e)
{
}
if(selectedCells!=null&&selectedCells.length>0&&selectionlayer!=null)
{
if(selectedCells1==null ||selectedCells1.length<=0)
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, false);
}
else if(selectedCells[0].getRowPosition()!=selectedCells1[0].getRowPosition())
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, false);
}
}
}
}
});
//When a row in left table is selected ,the full row of the right table is also selected
rightnatTable.addLayerListener(new ILayerListener(){
public void handleLayerEvent(ILayerEvent event) {
if(event instanceof RowSelectionEvent){
RowSelectionEvent rowEvent = (RowSelectionEvent) event;
SelectionLayer selectionlayer=leftbuilder.getBodyLayerStack().getSelectionLayer();
PositionCoordinate[] selectedCells =rowEvent.getSelectionLayer().getSelectedCellPositions();
PositionCoordinate[] selectedCells1=leftbuilder.getBodyLayerStack().getSelectionLayer().getSelectedCellPositions();
if(selectedCells!=null&&selectedCells.length>0&&selectionlayer!=null)
{
if(selectedCells1==null ||selectedCells1.length<=0)
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, true);
}
else if(selectedCells[0].getRowPosition()!=selectedCells1[0].getRowPosition())
{
selectionlayer.clear();
selectionlayer.selectRow(selectedCells[0].getColumnPosition(), selectedCells[0].getRowPosition(), false, true);
}
}
}
}
});
2.SCROLL:
//When we scroll vertical scrollbar of left table ,right table is also scrolled automatically.
//and When we scroll vertical scrollbar of right table ,left table is also scrolled automatically
leftnatTable.addListener(SWT.Selection, new VerticalScrollBarHandler(leftbuilder.getBodyLayerStack().getViewportLayer(),leftnatTable.getVerticalBar())
{
public void handleEvent(Event event)
{
//Code to avoid repetative execution
if(leftnatTable.getVerticalBar().getSelection()!=rightnatTable.getVerticalBar().getSelection())
{
rightnatTable.getVerticalBar().setSelection(leftnatTable.getVerticalBar().getSelection());
rightnatTable.getVerticalBar().notifyListeners(SWT.Selection, new Event());
}
}
});
rightnatTable.addListener(SWT.Selection, new VerticalScrollBarHandler(rightbuilder.getBodyLayerStack().getViewportLayer(),rightnatTable.getVerticalBar())
{
public void handleEvent(Event event)
{
if(leftnatTable.getVerticalBar().getSelection()!=rightnatTable.getVerticalBar().getSelection())
{
leftnatTable.getVerticalBar().setSelection(rightnatTable.getVerticalBar().getSelection());
leftnatTable.getVerticalBar().notifyListeners(SWT.Selection, new Event());
}
}
});
3:Filtering:
leftbuilder.getFilterList().addListEventListener(new ListEventListener(){
@Override
public void listChanged(ListEvent listEvent) {
Set filtersetList=new HashSet();
//Get the Data of filtered row
EventList eList=listEvent.getSourceList();
for(Iterator it = eList.iterator(); it.hasNext()
{
//the unique row number is extacted
EPLLine nextobj=(EPLLine)it.next();
String indx=nextobj.getEpllinerow();
int pos=Integer.parseInt(indx);
//the object of same row of anothe table is extacted
EPLLineModel eplmodel=(EPLLineModel)(rightbuilder.getEventList().get(pos));
filtersetList.add(eplmodel);
}
//The custom matcher to set the filter data to Right table
rightbuilder.getFilterList().setMatcher(new EPLTableMatcher(filtersetList));
rightbuilder.getNatTable().refresh();
}
});
The filtering of Left table based on filtered data of Right table is yet to be done.
Any advice for improvement will be appreciated.
|
|
|
|
|
|
|
|
|
|
Re: Row Filter [message #925140 is a reply to message #925059] |
Thu, 27 September 2012 12:13 |
dhruba kumar Messages: 51 Registered: September 2012 |
Member |
|
|
No Dirk, Its not the round-trip issue. As in my listChange code I 've changed the following things to see how many times the event propogates .
for Left Table:
MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK);
messageBox.setText("LeftFilter");
messageBox.setMessage("LeftFilter);
messageBox.open();
for RightTable listchange()
MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK);
messageBox.setText("RightFilter");
messageBox.setMessage("RightFilter);
messageBox.open();
Now when I add filter parameters in any table :
1.The messageBox shown just two times one with "LeftFilter" title and another with "RightFilter" and filters both the table properly. That means the round-trip is not the issue.
2.Now If I execute the "Clear-Filter"/further filter(i.e add more filter parameter on filter data) on the any of the filtered table the listchange event is not called as no message Box is showing and clear-filter/further filtering is not working.
i.e. Filtering on any table is working fine properly for the first time,for any any subsequent filtering/clearing its not working
Now If I comment/remove the
rightbuilder.getFilterList().addListEventListener(new ListEventListener(){...
the "leftbuilder.getFilterList().addListEventListener.." works properly for filtering /clear-filtering/further-filtering ,MessageBox is shown properly.
final Vector filtervc=new Vector();
filtervc.add("0");
leftbuilder.getFilterList().addListEventListener(new ListEventListener(){
@Override
public void listChanged(ListEvent listEvent) {
int rept=Integer.parseInt(filtervc.get(0).toString());
/*if(rept>=2)
{
filtervc.add(0,"0");
MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK);
messageBox.setText("Lrept0");
messageBox.setMessage("Rept::"+rept);
messageBox.open();
return;
}*/
rept++;
filtervc.add(0,new String(rept+""));
MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK);
messageBox.setText("Lrept1");
messageBox.setMessage("Rept::"+rept);
messageBox.open();
Set filtersetList=new HashSet();
EventList eList=listEvent.getSourceList();
for(Iterator it = eList.iterator(); it.hasNext()
{
EPLLine nextobj=(EPLLine)it.next();
String indx=nextobj.getEpllinerow();
int pos=Integer.parseInt(indx);
EPLLineModel eplmodel=(EPLLineModel)(rightbuilder.getEventList().get(pos));
filtersetList.add(eplmodel);
}
FilterList fList=rightbuilder.getFilterList();
//if((fList.size()==filtersetList.size())&&(filtersetList.containsAll(fList)==true))
rightbuilder.getFilterList().setMatcher(new EPLTableMatcher(filtersetList));
//rightbuilder.getNatTable().notifyListeners(SWT.Selection, new Event());
}
});
Please advice
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06860 seconds