Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Problem using DateCellEditor(DateCellEditor sets the cell value to null)
Problem using DateCellEditor [message #1701736] Wed, 15 July 2015 09:52 Go to next message
Roma Lahoti is currently offline Roma LahotiFriend
Messages: 6
Registered: March 2015
Junior Member
Hi,
I am trying to show a date editor in one of the columns in my NAT UI.

I have included the following in my code :
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
new DateCellEditor(),DisplayMode.EDIT, DATE_LABEL);

On clicking that particular cell, i get a calendar instance to choose a date from.
I can easily choose different dates from it. But the moment i shift to any other cell, the date cell value becomes empty.

i have a check in setDataValue() :
if (userValue == null)
super.setDataValue(columnIndex, rowIndex, "");
else
super.setDataValue(columnIndex, rowIndex, userValue.toString());

I am not sure why the userValue is null always in this case.
Am i missing anything here?
Attached are 2 screenshots for the same.

How can i set this selected date in the date column?
Re: Problem using DateCellEditor [message #1701745 is a reply to message #1701736] Wed, 15 July 2015 11:04 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
What do you mean with "i have a check in setDataValue()"?

I typically would say that you need to ensure a correct data type. The DateCellEditor needs a Date conversion to work correctly. So you need a DefaultDateDisplayConverter.
Re: Problem using DateCellEditor [message #1701832 is a reply to message #1701745] Thu, 16 July 2015 06:06 Go to previous messageGo to next message
Roma Lahoti is currently offline Roma LahotiFriend
Messages: 6
Registered: March 2015
Junior Member
Hello Dirk,

I am already using a DefaultDateDisplayConverter.

configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
new DefaultDateDisplayConverter(),DisplayMode.NORMAL,
DATE_LABEL);

configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER,
new DefaultDateDisplayConverter(),DisplayMode.EDIT,
DATE_LABEL);

But it displays message : Cannot format given Object as a Date at org.eclipse.nebula.widgets.nattable.data.convert.DefaultDateDisplayConverter canonicalToDisplayValue.

if i double click a particular cell to edit and enter nothing , the pointer gets stuck in that cell when i try to shift to another cell. For this I am overriding the setDataValue to check for blank data
if (userEnteredValue == null)
super.setDataValue(columnIndex, rowIndex, "");
else
super.setDataValue(columnIndex, rowIndex, userEnteredValue.toString());

I am not sure what is missing.
On digging more into the code, i see that null value is passed as date to DateCellEditor , I don't know why. As on the UI , I am able to see the selected date.
Re: Problem using DateCellEditor [message #1701834 is a reply to message #1701832] Thu, 16 July 2015 06:34 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Quote:
Cannot format given Object as a Date at org.eclipse.nebula.widgets.nattable.data.convert.DefaultDateDisplayConverter


Well, that message says everything. The object in your data model is not a Date.

And where did you override setDataValue()? DataLayer? IDataProvider? It looks like you are setting a String. So is the value in your data model a String? Why should that work in conjunction with Dates?
Re: Problem using DateCellEditor [message #1701839 is a reply to message #1701834] Thu, 16 July 2015 07:10 Go to previous messageGo to next message
Roma Lahoti is currently offline Roma LahotiFriend
Messages: 6
Registered: March 2015
Junior Member
Hello,

I am overriding the setDataValue() in bodyDataLayer. I am setting string values for rest of the columns
For this particular date column, my setDataValue() has something like this:

if(columnIndex== <<dateColumnIndex>>)
{
Object cal = cellEditor.getEditorValue();
super.setDataValue(columnIndex, rowIndex, cal );
}
else if (userEnteredValue == null)
super.setDataValue(columnIndex, rowIndex, "");
else
super.setDataValue(columnIndex, rowIndex, userEnteredValue.toString());

-Roma Lahoti

Re: Problem using DateCellEditor [message #1701840 is a reply to message #1701839] Thu, 16 July 2015 07:15 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Sigh ... for such things converters should be used. But if you like it more to override internal methods to achieve behavior that can be configured, go ahead and loose the ability to update and get bugfixes and new features in the future.

I really don't understand why most of the cases reported here in the forum use overriding in favor of configuration.
Previous Topic:NatTable in Eclipse RAP with RAPe4 Incubator
Next Topic:Installation Error
Goto Forum:
  


Current Time: Tue Mar 09 05:07:46 GMT 2021

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

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

Back to the top