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

Author Topic: List within a text field  (Read 4528 times)

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
List within a text field
« 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

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #1 on: October 10, 2017, 11:35:30 AM »
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

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: List within a text field
« Reply #2 on: October 11, 2017, 09:11:45 AM »
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??

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #3 on: October 11, 2017, 01:12:16 PM »
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?

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: List within a text field
« Reply #4 on: October 11, 2017, 03:58:48 PM »
Yes, I will get a "list" of orders for a given Customer out of the database.

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #5 on: October 11, 2017, 05:38:00 PM »
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?


Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: List within a text field
« Reply #6 on: October 11, 2017, 06:19:35 PM »
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

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #7 on: October 11, 2017, 06:32:32 PM »
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

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: List within a text field
« Reply #8 on: October 12, 2017, 02:54:59 PM »
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?

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #9 on: October 12, 2017, 06:31:26 PM »
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

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #10 on: October 12, 2017, 07:03:51 PM »
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

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: List within a text field
« Reply #11 on: October 13, 2017, 09:25:44 AM »
thanks for your help

I will try the script and variable solution and see where it gets me  :D

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #12 on: October 13, 2017, 10:00:37 AM »
Well Let's try it :D

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: List within a text field
« Reply #13 on: October 13, 2017, 03:59:52 PM »
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

Subst

  • Sr. Member
  • ****
  • Posts: 444
    • View Profile
Re: List within a text field
« Reply #14 on: October 13, 2017, 05:20:31 PM »
You are welcome :)
I am pleased to help