Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Different Cell types in the same column
Different Cell types in the same column [message #1278700] Thu, 27 March 2014 18:34 Go to next message
Dominic Hanlan is currently offline Dominic HanlanFriend
Messages: 98
Registered: July 2009
Member
Hi,

I have a questionare form that has varying answer types, some date, some drop down and some numeric. Is it possible to change the cell type of a column on a row by row basis.

i.e.

Question | Answer
--------------------

DOB | Date Field
Gender | Smart Field



(apologies for the formatting)

Regards
Re: Different Cell types in the same column [message #1278724 is a reply to message #1278700] Thu, 27 March 2014 19:16 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Yes and No.

I mean you need a Type for your column, but this type can be Object.

In this case you need to handle:
- What will be displayed in the Cell: execDecorateCell
- The field that will be used when your value is edited: execPrepareEdit


public class AnswerColumn extends AbstractColumn<Object> {

      @Override
      protected String getConfiguredHeaderText() {
        return TEXTS.get("Answer");
      }

      @Override
      protected void execDecorateCell(Cell cell, ITableRow row) throws ProcessingException {
        if(CompareUtility.equals("DOB", getQuestionColumn().getValue(row))) {
          cell.setText(DateUtility.format((Date)getValue(row), "yyyy-mm-dd"));
        } else if (CompareUtility.equals("Gender", getQuestionColumn().getValue(row))) {
          cell.setText(getValue(row).toString());
        }
      }

      @Override
      protected IFormField execPrepareEdit(ITableRow row) throws ProcessingException {
        if(CompareUtility.equals("DOB", getQuestionColumn().getValue(row))) {
          return <a date field>;
        } else if (CompareUtility.equals("Gender", getQuestionColumn().getValue(row))) {
          return <a smart field>;
        }
      }
}


Instead of testing the value QuestionColumn you should consider adding an undisplayable column containing information about the type of the AnswerColumn.

That said, I am still asking me if this pattern makes sense. I am not convinced, but it probably depends on your use case.


.
Re: Different Cell types in the same column [message #1278764 is a reply to message #1278724] Thu, 27 March 2014 20:29 Go to previous messageGo to next message
Dominic Hanlan is currently offline Dominic HanlanFriend
Messages: 98
Registered: July 2009
Member
Hi,

that's exactly what I needed, I have an undisplayed type field so its all good .....

Many thanks

Re: Different Cell types in the same column [message #1279277 is a reply to message #1278764] Fri, 28 March 2014 13:58 Go to previous messageGo to next message
Dominic Hanlan is currently offline Dominic HanlanFriend
Messages: 98
Registered: July 2009
Member
--- Ignore ---

[Updated on: Fri, 28 March 2014 14:08]

Report message to a moderator

Re: Different Cell types in the same column [message #1279316 is a reply to message #1279277] Fri, 28 March 2014 15:11 Go to previous messageGo to next message
Dominic Hanlan is currently offline Dominic HanlanFriend
Messages: 98
Registered: July 2009
Member
Hi,

Not quite ... I'm using a lookupCall on my smart fields and they are parameterised, the value I'm getting back in the execDecorateCell() is the index not the "Text" value of the selection. Is there a way of getting at the LookupRow that was selected in the smart field not just its index value??

Regards
Re: Different Cell types in the same column [message #1280980 is a reply to message #1279316] Mon, 31 March 2014 07:20 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Yes...

If performance is not an issue you can have a look at Accessing a LookupRow directly. I think you can use this to get the text corresponding to your key.

If you want to optimize those call, you can check how the AbstractSmartColumn is doing (with batch Lookup and so on).

You can access the text corresponding to a the selected key in a SmartField by calling getDisplayText() on the field. But for this you need to have the field instance. This is probably the case in execCompleteEdit(..). Not sure you can decorate the cell at this point.

Let me know...

.
Re: Different Cell types in the same column [message #1281058 is a reply to message #1280980] Mon, 31 March 2014 09:51 Go to previous messageGo to next message
Dominic Hanlan is currently offline Dominic HanlanFriend
Messages: 98
Registered: July 2009
Member
Hi,

big problems with the basic method outlined in your original reply. When the field is first edited and I hit enter the value is shown. If I then re-edit the field the original value is still shown when I hit enter. If I then re-edit the field and hit enter the previous edit value is shown, i.e. the row value is always one behind.

What am I missing???

Regards

[Updated on: Mon, 31 March 2014 09:52]

Report message to a moderator

Re: Different Cell types in the same column [message #1283248 is a reply to message #1281058] Thu, 03 April 2014 07:46 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I expect it to work.

Have a look with the debugger, what happens when the edit is completed. Compare it with the default case.

It would help if you could reduce your case to a simple example (code of your table with the 3 columns we discussed and some data in the table) that can be used independently from your application and if you would share it here...
Previous Topic:Label Position for AbstractBooleanField
Next Topic:IShellService cannot open file
Goto Forum:
  


Current Time: Tue Mar 19 07:10:57 GMT 2024

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

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

Back to the top