LimeReport Forum
General Category | Основное => Discussion | Обсуждение => Topic started by: Paul Traut on October 10, 2017, 10:06:29 am
-
Hello, is it possible to get a list within a text field?
My idea is to show a list depending on the entry in the text field above.
My situation:
I have a text field with a customer and would like to see all orders for this customer in the text field below.
Thanks
Paul
-
Hi! Why U can't use SubDetail band?
If you wanna customize text within text item use scripts and/or magic '\n' string for start new string
-
Hi,
I have tried to use SubDetail band, but till now do not get the right results.
Is there anywhere a good documentation on how to use scripts??
-
No, no docs for scripts as I know. Just some examples on git within sources. Here https://github.com/fralx/LimeReport
So scripts use the syntax like Java Script
>> I have a text field with a customer and would like to see all orders for this customer in the text field below.
The data in database?
-
Yes, I will get a "list" of orders for a given Customer out of the database.
-
well, I've two tables?
First - the Customers and another one - the Orders? Like this
Customers
_______________________
id | Customer | Some else
Orders
_____________________________________
id | Customer_id | Order | Date | Some else
Isn't it?
-
yes right and now i would like to count all orders for a customer and list every order within one text field in a report
-
You need to create databand and set datasource for it to Customers,
Also need to subdetailband and set the datasource fro it to Orders
(about this step you can read in UserManualPdf.pdf page 11 and futher)
In textitem on subdeatail
you can set contents as
simple:
$D{orders.id}
$D{orders.order}
$D{orders.some_thing_else}
or
more complex with script:
$S{
$D{orders.id}+"\n"+$D{orders.order}+"\n"+$D{orders.some_thing_else};
}
result the same
-
Ok, I have used a new data band now and have nearly the result I need.
The problem now is I get something like
.
.
----------------------------
orders | order_name_1|...
----------------------------
orders | order_name_2|...
----------------------------
orders | order_name_3|...
----------------------------
and so on but I would like to have something like
.
.
----------------------------
| order_name_1|...
orders | order_name_2|...
| order_name_3|...
----------------------------
Is this possible?
-
easy you can get such result
orders
_________________________
| order_name_1
_________________________
| order_name_2
_________________________
etc...
As for result like
----------------------------
| order_name_1|...
orders | order_name_2|...
| order_name_3|...
----------------------------
I think it's needed to use scripts and one variable in report.
I've tired, may be tommorow try to help you
-
ok..during 10 or 15 minutes I'm here
The main idea it's create the variavle in report, for example 'first' and set initial value for it to 'true'
in text item write like this
$S{
if (getVariable('first')==1)
{
setVariable('first',0);
$D{YOUR_TABLE.YOUR_FIELD};
}
else
"";
}
such $D{YOUR_TABLE.YOUR_FIELD} will be written first time and not written other times
-
thanks for your help
I will try the script and variable solution and see where it gets me :D
-
Well Let's try it :D
-
Again, thanks for your help :D
Now I have the solution I need.
$S{
if (getVariable("first")==1)
{
setVariable("first","2");
"My Text"
}
else if (getVariable("first")==2)
{
setVariable("first","0");
"second Line Text"
}
else
"";
}
now i have to figure out how to display the second line even if only one data is given ;D
-
You are welcome :)
I am pleased to help