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

Author Topic: How to add External datasets in LRDesigner?  (Read 1123 times)

hamlettu

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to add External datasets in LRDesigner?
« on: November 19, 2021, 11:44:32 AM »
Hi
I read user manual, in DATA SOURCES session(page 5),
it say "External datasets by implementing QAbstractItemModel".
I want to use external datasets in my app like demo_r1.
I see the picture in user manual,
there are external_customers_data and external_orders_data look like root node.

I try to add "Dataset", but it need to use a exist Datasource and sql.
And the Dataset is a child node of Datasource.

How to add External datasets in LRDesigner?

Thanks

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 992
    • View Profile
Re: How to add External datasets in LRDesigner?
« Reply #1 on: November 23, 2021, 07:12:18 PM »
Hi!
The simplest way to add an external data source is to realize one slot callback data source.
Just do something like this:
Code: [Select]
void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
{
    QStringList columns;
    columns << "Name" << "Value" << "Image";
    switch (info.dataType) {
            case LimeReport::CallbackInfo::RowCount:
                data = 4;
                break;
            case LimeReport::CallbackInfo::ColumnCount:
                data = columns.size();
                break;
            case LimeReport::CallbackInfo::ColumnHeaderData: {
                data = columns.at(info.index);
                break;
            }
            case LimeReport::CallbackInfo::ColumnData:
                qDebug() << info.index <<info.columnName;
                if (info.columnName == "Image")
                    data = QImage(":/report//images/logo32");
                else {
                    data = info.columnName+" "+QString::number(info.index);
                }
                break;
            default: break;
        }
}

.....

callbackDatasource = report->dataManager()->createCallbackDatasource("oneSlotDS");
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
            this, SLOT(slotOneSlotDS(LimeReport::CallbackInfo,QVariant&)));

 

hamlettu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to add External datasets in LRDesigner?
« Reply #2 on: November 24, 2021, 08:42:38 AM »
Alex,
Thanks.
I will try.