Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 9 of 9 total |
Assign dataset to grid at runtime |
Wed, Oct 14 2015 5:27 AM | Permanent Link |
Petter Topp | What would be the best way to assign a dataset to the same grid at run time?
I have several datasets that should be displayed in the same grid at run time. Given the fact that the datasets are different in every way, I will need to create the columns specific for each dataset at run-time. With the new ewb2 grid how do I accomplish this (iterate and free TGridColumn then Create manually)? Alternatively - Create and free the TGrid entirely and assign dataset? Best regards Petter |
Wed, Oct 14 2015 2:03 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Petter,
<< With the new ewb2 grid how do I accomplish this (iterate and free TGridColumn then Create manually)? >> This. Tim Young Elevate Software www.elevatesoft.com |
Thu, Oct 15 2015 1:20 AM | Permanent Link |
Petter Topp | Tim, how do I assign a TGridColumn to a grid?
TGridColumn.ParentGrid is read Petter |
Thu, Oct 15 2015 3:10 AM | Permanent Link |
Petter Topp | Newer mind, I found the NewColumn method of the Grid.
procedure AssignDatasetToGrid(ADataSet: TDataSet; AGrid: TGrid); var i: Integer; col: TGridColumn; begin DataBase.LoadRows(ADataSet); AGrid.DataSet := ADataSet; for i := 0 to ADataSet.ColumnCount -1 do begin col := AGrid.NewColumn; col.DataColumn := ADataSet.columns[i].Name; col.Header.Caption := ADataSet.columns[i].Name; end; end; Works perfectly |
Thu, Oct 15 2015 3:57 AM | Permanent Link |
Petter Topp | Oops, it seems that I was a little fast in concluding...
If I use the method AssignDataSet (Grid.NewColumn) in previous post , it seems that no TGridColumns are created. So the following method won't work: What am I missing? procedure FreeGridColumns(AForm: TForm; AGrid: TGrid); var i: integer; comp: TComponent; begin AGrid.Dataset := Nil; for i := AForm.componentcount - 1 downto 0 do begin comp := AForm.component[i]; if TControl(comp) is TGridColumn then begin comp.free; end; end; end; |
Thu, Oct 15 2015 1:23 PM | Permanent Link |
Petter Topp | Anyone?
After initially removing (free) GridColumns created at design time I'm creating the new GridColumns which show up nicely and the grid works fine. However - the componentcount before I performed a free initially was 20, after removing the GridColumns the count was 12, and remained 12 even after I had them created. I'm obiously not creating the new GrodColumns the correct way. Any suggestions appreciated... Petter |
Thu, Oct 15 2015 2:37 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Petter,
<< Anyone? >> You have to allow time for someone to answer. I don't monitor the support forums all day, usually just once or twice a day. << After initially removing (free) GridColumns created at design time I'm creating the new GridColumns which show up nicely and the grid works fine. However - the componentcount before I performed a free initially was 20, after removing the GridColumns the count was 12, and remained 12 even after I had them created. >> Are you *always* creating the grid columns at runtime, or do you have some columns defined at design-time ? The issue here is two-fold: 1) When you grid columns at design-time, the *Parent* of the grid column is the TGrid, but the containing form becomes the *Owner* of the grid columns. 2) When you create grid columns at run-time, the *Parent and the Owner* of the grid column will be the TGrid. This is the best way to destroy the grid columns at run-time: procedure FreeGridColumns(AGrid: TGrid); var i: integer; begin AGrid.Dataset := Nil; for i := AGrid.Columncount - 1 downto 0 do AGrid.Columns[i].Free; end; Tim Young Elevate Software www.elevatesoft.com |
Fri, Oct 16 2015 1:08 AM | Permanent Link |
Petter Topp | Tim, sorry for being impatient, but the frustration of not getting anywhere with a simple issue was getting to me. Even worse, after getting your explanation of the issue, is my lacking ability to figure it out my self...
Br Petter |
Fri, Oct 16 2015 12:04 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Petter,
<< Tim, sorry for being impatient, but the frustration of not getting anywhere with a simple issue was getting to me. Even worse, after getting your explanation of the issue, is my lacking ability to figure it out my self... >> If you run into such an issue, just email support@elevatesoft.com for a faster response. On that subject, I looked at your customer records and noticed that you didn't have any support sessions credited to you during the switch-over to the new support model. Somehow, our calculations for the grandfathered support sessions missed you due to the timing of when you last purchased, etc. so I had Sam credit you with 4 support sessions that you can use whenever you want. You've been a customer for a long time and it's not right that you weren't given some support sessions to use. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Saturday, January 18, 2025 at 07:39 AM | Privacy PolicySite Map © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |