LimeReport Forum
		General Category | Основное => Discussion | Обсуждение => Topic started by: maurosanjo on December 02, 2016, 06:22:22 pm
		
			
			- 
				I made a code to study how the callback mechanism works with diferrent band arrangements.
 
 When we have a Data band with a Group Header and with a Group Footer. We put, for instance, 4 fields on data band, that will correspond to columns of each row data. So on LimeReport::CallbackInfo::ColumnCount we set the number of rows = 4.
 But if I put text fields in Group Header or Footer using $D{}, the data never gets fetched on getCallbackData.
 
 How can it be done imagining we want different values for each Group Header and Footer fields.
 
 Regards
- 
				Can you send me an example ? 
			
- 
				Hello Arin,
 
 There is a sample page I was testing on version 1.4. Imagine I want to set a differente value for each field on group header and footer bands, not using DB sources, just the signal and slot mechanism you called callback.
 
 The names of the fields in $D are not used in this signal & slot mechanism right? I was testing different patterns.
 
 Regards
 
 [вложение удалено администратором]
- 
				Hi maurosanjo !
 The GroupBandHeader and GroupBandFooter bands are designed to create a data grouping
 and you must specify a field that will be used for grouping (groupField property of the GroupBandHeader)
 when value in that field is changed new group is created.
 There is a sample how to use GroupBandHeader and GroupBandFooter. (only for version 1.4 and higher)
 If you want simple data header and footer you should use DataHeader and DataFooter bands
 
 [вложение удалено администратором]
- 
				Sorry Arin, on my sample I forgot to put a test group field. That is working correctly.
 
 My question is regarding custom data ON the header and footer that are not coming from DataBase data sources. How do I implement the GetCallBackData slot so I can get a request to set the values of the fields on the group header and footer?
 
 See my sample code below, in my sample I sent you, I have four columns of data and 1 field on group header and 2 on group footer. But this way I only get a call for the 4 data fields and the groupField. I don't know if I could make myself clear, please let me know if you did not understand  ;)
 
 void ReportsGenerator::LRGetCallbackData2(LimeReport::CallbackInfo info, QVariant &data) {
 switch (info.dataType) {
 case LimeReport::CallbackInfo::RowCount:
 qDebug() << "P2 RowCount - i" << info.index << " - " << info.columnName << " - r " << this->_currentRow;
 data = 4;
 break;
 case LimeReport::CallbackInfo::ColumnCount:
 qDebug() << "P2 ColumnCount - i" << info.index << " - " << info.columnName << " - r " << this->_currentRow;
 data = 4;
 break;
 case LimeReport::CallbackInfo::IsEmpty:
 qDebug() << "P2 IsEmpty - r " << this->_currentRow << " - " << info.columnName;
 data = true; //!ds->first();
 break;
 case LimeReport::CallbackInfo::ColumnHeaderData: {
 switch(info.index) {
 case 0:
 data = "Name1";
 break;
 case 1:
 data = "Value1";
 break;
 case 2:
 data = "Name2";
 break;
 case 3:
 data = "Value2";
 break;
 }
 qDebug() << "P2 HeaderData - " << info.index << " - " << data.toString();
 break;
 }
 case LimeReport::CallbackInfo::ColumnData:
 qDebug() << "P2 Requested - i - " << info.index << " - " << info.columnName << " - r " << this->_currentRow;
 if (info.columnName == "SamplesGroup")
 data = "Resultados Gerais";
 else {
 data = "Data";
 }
 break;
 default: break;
 }
 }
 
- 
				I think I understand  :)
 At first in your code
 case LimeReport::CallbackInfo::IsEmpty:
 qDebug() << "P2 IsEmpty - r " << this->_currentRow << " - " << info.columnName;
 data = true; //!ds->first();
 break;
 
 data should be false otherwise callback dataset will be empty
 
 Secondly all fields which you want to use in the report should be described by ColumnHeaderData
 
 void ReportsGenerator::LRGetCallbackData2(LimeReport::CallbackInfo info, QVariant &data) {
 switch (info.dataType) {
 case LimeReport::CallbackInfo::RowCount:
 qDebug() << "P2 RowCount - i" << info.index << " - " << info.columnName << " - r " << this->_currentRow;
 data = 4;
 break;
 case LimeReport::CallbackInfo::ColumnCount:
 qDebug() << "P2 ColumnCount - i" << info.index << " - " << info.columnName << " - r " << this->_currentRow;
 data = 5;
 break;
 case LimeReport::CallbackInfo::IsEmpty:
 qDebug() << "P2 IsEmpty - r " << this->_currentRow << " - " << info.columnName;
 data = false; //!ds->first();
 break;
 case LimeReport::CallbackInfo::ColumnHeaderData: {
 switch(info.index) {
 case 0:
 data = "Name1";
 break;
 case 1:
 data = "Value1";
 break;
 case 2:
 data = "Name2";
 break;
 case 3:
 data = "Value2";
 break;
 case 4:
 data = "SamplesGroup";
 break;
 }
 qDebug() << "P2 HeaderData - " << info.index << " - " << data.toString();
 break;
 }
 case LimeReport::CallbackInfo::ColumnData:
 qDebug() << "P2 Requested - i - " << info.index << " - " << info.columnName << " - r " << this->_currentRow;
 if (info.columnName == "SamplesGroup")
 data = "Resultados Gerais";
 else {
 data = "Data";
 }
 break;
 default: break;
 }
 }
 
 
 
- 
				Thanks, got it  :)
			
- 
				You are welcome