Different Cell types in the same column [message #1278700] |
Thu, 27 March 2014 14:34  |
Eclipse User |
|
|
|
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 15:16   |
Eclipse User |
|
|
|
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 #1283248 is a reply to message #1281058] |
Thu, 03 April 2014 03:46  |
Eclipse User |
|
|
|
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...
|
|
|
Powered by
FUDForum. Page generated in 0.25115 seconds