The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Can you show a count of a field in a grid?
Posted: 02 Jan 08 12:49 PM
|
Sorry for posting 2 newbie questions close to gether but I have been working with a data grid and I have some fields that are showing up. I would like to take a count of records in a different table that relate to the record(s) show in the grid
example:
grid data from table a but would like to count the records that relate in b and show as a field in the grid
a.name b.recordcount ( count(*) )
hopes this makes sense..... |
|
|
|
Re: Can you show a count of a field in a grid?
Posted: 03 Jan 08 2:14 AM
|
Hi Chip,
This can be done simply IF you do not have Remote Users to 'worry' about. You could also do this to include Remote Users but it would be a much more cumbersome build.
If you would like to know the simple, non-remote way, please let me know which version you are running first as this works best (most simply!) in versions 7.x - you can also do this for version 6.x but again, slightly more of a pain to do.
Mark |
|
|
|
Re: Can you show a count of a field in a grid?
Posted: 03 Jan 08 5:19 AM
|
If you are on 7.x, you could define a sql view and then use that as the basis for your grid.
Otherwise, you can build the grid at run time with code, and display the count like it's any other data field.
ws |
|
|
| |
| |
|
Re: Can you show a count of a field in a grid?
Posted: 03 Jan 08 8:11 AM
|
Hi Chip,
Indeed - you define this outside SLX (i'm using SQL but you'll get the gist...)
For instance, below is a SQL script to create a view:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE view [sysdba].[SALESORDER_COUNT] as ( SELECT accountid,count(salesorderid) as cnt FROM sysdba.SALESORDER where status <> 'Cancelled' and ordertype = 'OR' group by accountid )
This view simply has a column 'ACCOUNTID' and a count of SALESORDERS per account
Once the view has been created, you can use this in your standard forms / datagrids by joining (in this example ACCOUNT.ACCOUNTID left outer join to SALESORDER_COUNT.ACCOUNTID)
Let me know if this is not clear to you - otherwise, have fun !
Mark |
|
|
|
Re: Can you show a count of a field in a grid?
Posted: 04 Jan 08 2:03 AM
|
Update... I did ask about Remote Users on my earlier reply but I believe Remotes will also get the view too (obviously will only work as long as the views reference sync'd tables) so ignore that remark! |
|
|
|