Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Using Callbacks how to set custom text fields for group header and footer  (Read 5165 times)

maurosanjo

  • Newbie
  • *
  • Posts: 10
    • View Profile
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

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #1 on: December 04, 2016, 11:13:44 pm »
Can you send me an example ?

maurosanjo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #2 on: December 04, 2016, 11:38:12 pm »
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

[вложение удалено администратором]

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #3 on: December 05, 2016, 11:37:43 am »
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

[вложение удалено администратором]
« Last Edit: December 05, 2016, 12:12:35 pm by Arin Alex »

maurosanjo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #4 on: December 05, 2016, 12:34:54 pm »
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  ;)

Code: [Select]
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;
    }
}

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #5 on: December 05, 2016, 05:32:13 pm »
I think I understand  :)
At first in your code
Quote
Code: [Select]
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

Code: [Select]
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;
    }
}


« Last Edit: December 05, 2016, 07:26:39 pm by Arin Alex »

maurosanjo

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #6 on: December 05, 2016, 07:24:20 pm »
Thanks, got it  :)

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Using Callbacks how to set custom text fields for group header and footer
« Reply #7 on: December 05, 2016, 07:28:01 pm »
You are welcome