Hi,
If I want to have a subtotal or total in the table (grid), what should I do? Any example I can follow?
Thanks in advance for the help.
Sub total and total in a table?
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Is the table being used for a report or is editable?
If a report then you can can load your data into your table, and then process it to insert rows for sub-totals and totals as you need. Then just present the table on screen.
If editable then you could use nested repeaters instead of a table controls to present the data. For example, your parent repeater can hold sub-totals for each nested child repeater, etc. Obviously you'd have to handle the events associated with people editing the data.
Or, you could plug-in a 3rd party grid with this sort of functionality and simply bind your Ebase data to it via the Client API. We have used Kendo Gridhttp://demos.telerik.com/kendo-ui/grid/index and SmartClient controls http://www.smartclient.com/#summaryGridFS before, for example, but there are literally hundreds out there.
If a report then you can can load your data into your table, and then process it to insert rows for sub-totals and totals as you need. Then just present the table on screen.
If editable then you could use nested repeaters instead of a table controls to present the data. For example, your parent repeater can hold sub-totals for each nested child repeater, etc. Obviously you'd have to handle the events associated with people editing the data.
Or, you could plug-in a 3rd party grid with this sort of functionality and simply bind your Ebase data to it via the Client API. We have used Kendo Gridhttp://demos.telerik.com/kendo-ui/grid/index and SmartClient controls http://www.smartclient.com/#summaryGridFS before, for example, but there are literally hundreds out there.
0 x
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Nested repeaters: a simple example, we have two database tables:
invoices: invoice_id, invoice_no, invoice_descr
invoice_lines: invoice_id, line_descr, amount
The relationship is that invoices have one or more invoice_lines.
We want to see both tables laid out, one within the other, but with a total for each invoice.
So, create one Ebase table (say, table1) backed by SQL like:
select invoice_id, line_descr, amount from invoice_lines;
This is just your invoice_lines data.
Create a second table (say, table2) backed by:
select i.invoice_id invoice_id, invoice_no, invoice_total.total
from invoices i,(select invoice_id, sum(amount) total from invoice_lines group by invoice_id) invoice_total
where i.invoice_id = invoice_total.invoice_id;
This one will hold a total value for each invoice, plus other invoice details.
Now create a REPEATER against the first table (the invoice lines).
And a REPEATER against the second table (the invoice header and total).
Nest the first REPEATER within the second one, and add a filter expression to the first REPEATER to link it to the second, e.g. table2-invoice_id = table1-invoice_id
Now lay the REPEATER fields out however you like. Make sense? There is a downloadable example of nested repeaters in the new Vault you might find helpful.
In terms of validation, you can treat the fields in each REPEATER row exactly as you would do the columns in their corresponding table row (they are effectively the same thing). Current row is respected in the same way too, so processing is simple.
re. using the Designer if you use a 3rd party plug-in: yes, you continue to use the Designer, you just need to attach the plug-in to an Ebase element (such as a PANEL (Div)) according to the suppliers instructions.
If you find you're still struggling we could set up a session to show you how?
Dave
invoices: invoice_id, invoice_no, invoice_descr
invoice_lines: invoice_id, line_descr, amount
The relationship is that invoices have one or more invoice_lines.
We want to see both tables laid out, one within the other, but with a total for each invoice.
So, create one Ebase table (say, table1) backed by SQL like:
select invoice_id, line_descr, amount from invoice_lines;
This is just your invoice_lines data.
Create a second table (say, table2) backed by:
select i.invoice_id invoice_id, invoice_no, invoice_total.total
from invoices i,(select invoice_id, sum(amount) total from invoice_lines group by invoice_id) invoice_total
where i.invoice_id = invoice_total.invoice_id;
This one will hold a total value for each invoice, plus other invoice details.
Now create a REPEATER against the first table (the invoice lines).
And a REPEATER against the second table (the invoice header and total).
Nest the first REPEATER within the second one, and add a filter expression to the first REPEATER to link it to the second, e.g. table2-invoice_id = table1-invoice_id
Now lay the REPEATER fields out however you like. Make sense? There is a downloadable example of nested repeaters in the new Vault you might find helpful.
In terms of validation, you can treat the fields in each REPEATER row exactly as you would do the columns in their corresponding table row (they are effectively the same thing). Current row is respected in the same way too, so processing is simple.
re. using the Designer if you use a 3rd party plug-in: yes, you continue to use the Designer, you just need to attach the plug-in to an Ebase element (such as a PANEL (Div)) according to the suppliers instructions.
If you find you're still struggling we could set up a session to show you how?
Dave
0 x
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
Thank you for a quite detail explanation. I will try it first.
Dave wrote:Nested repeaters: a simple example, we have two database tables:
invoices: invoice_id, invoice_no, invoice_descr
invoice_lines: invoice_id, line_descr, amount
The relationship is that invoices have one or more invoice_lines.
We want to see both tables laid out, one within the other, but with a total for each invoice.
So, create one Ebase table (say, table1) backed by SQL like:
select invoice_id, line_descr, amount from invoice_lines;
This is just your invoice_lines data.
Create a second table (say, table2) backed by:
select i.invoice_id invoice_id, invoice_no, invoice_total.total
from invoices i,(select invoice_id, sum(amount) total from invoice_lines group by invoice_id) invoice_total
where i.invoice_id = invoice_total.invoice_id;
This one will hold a total value for each invoice, plus other invoice details.
Now create a REPEATER against the first table (the invoice lines).
And a REPEATER against the second table (the invoice header and total).
Nest the first REPEATER within the second one, and add a filter expression to the first REPEATER to link it to the second, e.g. table2-invoice_id = table1-invoice_id
Now lay the REPEATER fields out however you like. Make sense? There is a downloadable example of nested repeaters in the new Vault you might find helpful.
In terms of validation, you can treat the fields in each REPEATER row exactly as you would do the columns in their corresponding table row (they are effectively the same thing). Current row is respected in the same way too, so processing is simple.
re. using the Designer if you use a 3rd party plug-in: yes, you continue to use the Designer, you just need to attach the plug-in to an Ebase element (such as a PANEL (Div)) according to the suppliers instructions.
If you find you're still struggling we could set up a session to show you how?
Dave
0 x
Who is online
Users browsing this forum: No registered users and 21 guests