Sophis Risque: how to use LoadGeneralElement on a CSREditList declared in the transaction dialog?
Dec
6
Written by:
12/6/2013 1:14 PM
When trying to use LoadGeneralElement with a CSREditList declared in the transaction dialog, without mapping it to an Oracle table, it does not work. The method will return true when getting some value of one cell, but the output address won't be filled, even if GetGeneralLineCount returns the right number of lines.
Some piece of code has to be added, using the internal callbacks.
In fact, it works fine when the CSREditList is mapped to an Oracle table. The only way to use it is then to declare a fictive Oracle table in the constructor, with fictive fielsds for the columns. In order to disable the queries and insertions on the database, the internal methods CSREditList::WriteQuery and CSREditList::ReadQuery have to be overriden. These methods expect a short returned value corresponding to the CSRSqlQuery::Queryxxx returning code. It means that a successfull call of the method should return 0.
In conlusion, the following code will give the expected behaviour:
class CMyList : public sophis::gui::CSREditList
{
public:
CMyList(sophis::gui::CSRFitDialog *dialog,
int ERId_List,
const char *tableName="INVALID_TABLE",
int displayedLineCount=9999,
bool editable = false);
// internal methods
virtual short ReadQuery(char* result, _STL::vector& v)
{
return 0;
}
virtual short WriteQuery(char * resultat, _STL::vector& v)
{
return 0;
}
};
CMyList::CMyList(CSRFitDialog *dialog, int ERId_List,const char *tableName,int displayedLineCount, bool editable )
: CSREditList(dialog,ERId_List,tableName,displayedLineCount)
{
SSColumn* col;
fColumnCount = 1;
fColumns = new SSColumn[fColumnCount];
col = &fColumns[0];
col->fElement = new CSREditText(this,0,40,0,"FIELD0");
col->fColumnWidth = 90;
col->fAlignmentType = aLeft;
col->fColumnName = "MyColumn";
SetDynamicSize(true);
}
...
// somewhere in the constructor of the CSRTransactionDialog inherited class
fElementList[i++] = new CMyList(this, IDC_MYLIST-ID_ITEM_SHIFT);
....
void CMyAction::NotifyCreated(const CSRTransaction &transaction, tools::CSREventVector & message, long event_id)
{
transaction.LoadUserElement();
char _value[41];
*_usi = 0;
int _noline = 0;
int _nocol = 0;
int _nbline = transaction.GetGeneralLineCount(IDC_MYFIELD - ID_ITEM_SHIFT);
Boolean _res = transaction.LoadGeneralElement(IDC_MYFIELD - ID_ITEM_SHIFT,_noline,_nocol,_value);
}