Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Dynamic Column in Nattable
Dynamic Column in Nattable [message #1070636] Thu, 18 July 2013 11:10 Go to next message
dhruba kumar is currently offline dhruba kumarFriend
Messages: 51
Registered: September 2012
Member
Hi ,
I want to add column Dynamically in Nattable.

suppose I ve table "tab1". It has two columns ,column1 and column2.

Table is populated with data.

Now how to add a new column dynamically/programatically to tab1 .

To populate data I am using the code like this:

for (int i = 0; i < tabsize; i++) {
myList.add(new MyTableRow(data1,data2));
}

where MyTableRow implements TableRow with two properties ,for each column.

Now If I add new column how I will be able to populate data .

Like SWT ,whetherer I can add data to each column ,without defining MyTableRow:

swtrowItem_1.setText(j,rdata);


Please suggest.
Re: Dynamic Column in Nattable [message #1070677 is a reply to message #1070636] Thu, 18 July 2013 12:47 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Have a look at the example "Events - DynamicColumnExample"
Re: Dynamic Column in Nattable [message #1072663 is a reply to message #1070677] Tue, 23 July 2013 08:22 Go to previous messageGo to next message
dhruba kumar is currently offline dhruba kumarFriend
Messages: 51
Registered: September 2012
Member
Hi Dirk,
Thanks for your reply.

DynamicColumn is working .

Now I have the following queries:
1. In "DynamicColumnExample" sample , when I click on newly added column for sorting,the widget hangs.

2. For adding EDIT rule for cell I ve added the following code:


ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);

registerColumnLabels(labelAccumulator);

natTable.addConfiguration(new EditorConfiguration(columns)); //For EDIT Rule


public class EditorConfiguration extends AbstractRegistryConfiguration {

private ArrayList<String> columnLabel;

public EditorConfiguration(ArrayList<String> columnLabel)
{
this.columnLabel=columnLabel;
}

@Override
public void configureRegistry(IConfigRegistry configRegistry) {

for(int k=0;k<columnLabel.size();k++)
{



configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
IEditableRule.ALWAYS_EDITABLE,DisplayMode.EDIT,columnLabel.get(k));

registerSingleLineEditors(configRegistry,columnLabel.get(k));
}

}

But the Editor does not work . All the cell are disabled for Editing.


3. For Filter Row I ve added the following code:

private EventList values = GlazedLists.eventList(new ArrayList());

values.add(createValueRow("Homer"));
values.add(createValueRow("Marge"));
values.add(createValueRow("Bart"));
values.add(createValueRow("Lisa"));
values.add(createValueRow("Maggie"));


SortedList sortedRows = new SortedList(values, null);
filterList = new FilterList(sortedRows);

MyColumnPropertyAccessor columnPropertyAccessor=new MyColumnPropertyAccessor();
SimpleColumnHeaderDataProvider columnHeaderDataProvider =new SimpleColumnHeaderDataProvider();

final GlazedListsGridLayer glazedListsGridLayer = new GlazedListsGridLayer(
filterList,
columnPropertyAccessor,
columnHeaderDataProvider ,
configRegistry,
true);


....

glazedListsGridLayer.setColumnHeaderLayer(filterRowHeaderLayer);



But the Filter is not showing properly in Table
Re: Dynamic Column in Nattable [message #1072667 is a reply to message #1072663] Tue, 23 July 2013 08:29 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You need to register the configurations to your new columns after creation. As you register configurations against labels that correspond to your column, your new columns don't have the necessary configurations/labels.
Re: Dynamic Column in Nattable [message #1073785 is a reply to message #1072667] Thu, 25 July 2013 13:34 Go to previous messageGo to next message
dhruba kumar is currently offline dhruba kumarFriend
Messages: 51
Registered: September 2012
Member
Hi,
Thanks.
Now EDIT configuration is working .
1.But I am unable to add filterrow to this dynamic table( using GlazedListsGridLayer). 2.Filterrow should be updated when a new column is added i.e filter for newly added column should be shown

Re: Dynamic Column in Nattable [message #1073827 is a reply to message #1073785] Thu, 25 July 2013 15:02 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Well I suppose it is related to the filter configuration that also needs to be updated. That means rendering and handling of filtering.
Re: Dynamic Column in Nattable [message #1074544 is a reply to message #1073827] Sat, 27 July 2013 03:29 Go to previous messageGo to next message
dhruba kumar is currently offline dhruba kumarFriend
Messages: 51
Registered: September 2012
Member
Yes Dirk,
rendering and handling of filtering is required
Re: Dynamic Column in Nattable [message #1074662 is a reply to message #1074544] Sat, 27 July 2013 11:33 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Yes I already understood that. What I meant was that you need to ensure that also the filter configuration is updated regarding your dynamic columns.
Re: Dynamic Column in Nattable [message #1075479 is a reply to message #1074662] Mon, 29 July 2013 13:55 Go to previous messageGo to next message
dhruba kumar is currently offline dhruba kumarFriend
Messages: 51
Registered: September 2012
Member
Hi Dirk ,
for Dynamic column (GlazedListsGridLayer) there is no example for filtering.
can u please give some sample example or code snipplet.
Re: Dynamic Column in Nattable [message #1075512 is a reply to message #1075479] Mon, 29 July 2013 15:04 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
No I don't have an example. And sorry, also no time to create one. Have a look at the configuration to figure it out.
Previous Topic:Text exporter for nattable tree grid
Next Topic:[ColumnReorderEvent] Possible inconsistent behavior
Goto Forum:
  


Current Time: Thu Apr 18 12:37:06 GMT 2024

Powered by FUDForum. Page generated in 0.02183 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top