Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 14 total |
manually loading data into a grid |
Thu, May 22 2014 7:16 PM | Permanent Link |
Stephen Barker | Hi all,
I'm still evaluating EWB and just testing some things a bit deeper such as creating datasets from JSON etc, but hitting some problems. I broke my test app down into a real simple case but still could not see the data in the grid (originally loaded from a JSON string). Now I even removed the JSON stuff and hard coded some data as per the example in the manual but I still can't see the data in the grid. I must be missing something simple: procedure TfrmTestRemoteWeb.Button3Click(Sender: TObject); var pc : TDataColumn; begin Products.Close; Products.Columns.Clear; pc := Products.Columns.Add; pc.Name:='Id'; pc.DataType:=dtInteger; pc := Products.Columns.Add; pc.Name:='Code'; pc.DataType:=dtString; pc.Length:=20; pc := Products.Columns.Add; pc.Name:='Title'; pc.DataType:=dtString; pc.Length:=70; pc := Products.Columns.Add; pc.Name:='Price'; pc.DataType:=dtFloat; Products.Open; Products.Insert; Products.Columns['ID'].AsInteger := 100; Products.Columns['Code'].AsString := 'BSS12'; Products.Columns['Price'].AsFloat := 1500.50; Products.Save; Grid1.Dataset := Products; end; The grid is empty. Also I tried putting LogOutput calls in various places but they had no effect. thanks, Steve |
Fri, May 23 2014 12:21 AM | Permanent Link |
Stephen Barker | I gave up on the grid for now. The data is now getting into the dataset ok, but only for the first row. The subsequent rows fail:
Prod.Insert; Prod.Columns['Id'].AsInteger := 100; Prod.Columns['Code'].AsString := 'BSS12'; Prod.Columns['Price'].AsFloat := 1500.50; Prod.Save; Prod.Insert; Prod.Columns['Id'].AsInteger := 200; Prod.Columns['Code'].AsString := 'BSS14'; Prod.Columns['Price'].AsFloat := 2500.50; Prod.Save; Prod.Insert; Prod.Columns['Id'].AsInteger := 300; Prod.Columns['Code'].AsString := 'BSS16'; Prod.Columns['Price'].AsFloat := 3500.50; Prod.Save; This gives an error: Column index 0 out of bounds. Line: 14764, after the first row is inserted. Any single one of the above rows work on their own, just not more than 1 at a time. Steve |
Fri, May 23 2014 1:43 AM | Permanent Link |
Stephen Barker | OK, I've got past the multiple row issue, but not sure what the problem was. I removed the grid completely. Replaced the Tdataset. Replaced my EWB 102b2 with EWB 103b5 trial. Had more issues with program files paths because of that. Replaced the grid.
Now the RowCount correctly states 3. I'll go back to trying to display the data in the grid, then supplying the data from a JSON string. Steve. |
Fri, May 23 2014 1:48 AM | Permanent Link |
Stephen Barker | Stephen Barker wrote:
I'll go back to trying to display the data in the grid, then supplying the data from a JSON string. Nope - I still get this error when using the data in a grid: Column index 0 out of bounds |
Fri, May 23 2014 4:06 AM | Permanent Link |
Chris Holland SEC Solutions Ltd. Team Elevate | Can you post your project here so we can see the code in full?
Chris Holland [Team Elevate] On 23/05/2014 06:48, Stephen Barker wrote: > Stephen Barker wrote: > I'll go back to trying to display the data in the grid, then supplying the data from a JSON string. > > Nope - I still get this error when using the data in a grid: > Column index 0 out of bounds > |
Fri, May 23 2014 5:19 AM | Permanent Link |
Matthew Jones | I think I'd start a little more step-wise. Start with the grid and
manually add the columns, and then see if your adding the data causes the message. If not, then you know it is the column creation. I note that the first column is called "Id" but you add data to "ID", and not sure if that is case sensitive. I think I'd also look at the framework code to check the actions of Products.Columns.Clear - it could be that this is removing a hidden control column. Just some thoughts - when I used the grid, loaded myself, I didn't have issues, but I used pre-defined columns. -- Matthew Jones |
Fri, May 23 2014 7:33 AM | Permanent Link |
Stephen Barker | "Matthew Jones" wrote:
I think I'd start a little more step-wise. Start with the grid and manually add the columns, and then see if your adding the data causes the message. If not, then you know it is the column creation. Thanks. I already moved ahead with displaying the data in other ways (listbox, then panels), but tried your suggestion and it worked. If I create the dataset columns at design time, then assign the dataset to the grid at design time, it automatically creates the grid columns to match the dataset. Then at run time I can populate the dataset and it shows in the grid just fine. I guess it has something to do with the columns.clear as you suggest. The problem is I don't want to define everything at design time, so I'll have to do some more testing to use grids. Anyone got any ideas why the LogOutput isn't working? Steve |
Fri, May 23 2014 8:35 AM | Permanent Link |
Matthew Jones | Stephen Barker wrote:
> Anyone got any ideas why the LogOutput isn't working? I have no idea, not used it myself. I just have a Report(szMessage : String) function, and that puts the string at the end of a TMemo on the web page. The memo is on a panel, with a splitter, and both are normally hidden unless you double click the header panel, at which point they appear. In more advanced versions, you have to do other things. But this means that I can see, in the browser, the "thinking" underneath the actions that are happening. -- Matthew Jones |
Fri, May 23 2014 9:43 AM | Permanent Link |
Chris Holland SEC Solutions Ltd. Team Elevate | Did you have the Message Pane open (View -> Messages from menu)
Or else you will not see them. Chris Holland > > Anyone got any ideas why the LogOutput isn't working? > > Steve > |
Tue, Jun 17 2014 9:14 PM | Permanent Link |
Stephen Barker | Hi all
Back onto the original subject - I'm trying once again to load data at run time into a grid. I have got a little bit further by creating a column in the grid to match each column in the dataset. Before that, I had assumed that would be done for me, like in Delphi. Now it shows a grid with the correct number of columns and rows but they are all empty and all the same small size. When I click on the cells in the grid the data values then appear (but not the column headings). Do I have to size each column to match the field widths? And how do I refresh the grid to show the field content and column headings? on form show: procedure TfrmCart.frmCartShow(Sender: TObject); var i : integer; dc : TDataColumn; s : string; begin Grid1.DataSet := nil; Grid1.Columns.Clear; Grid1.DataSet := frmMain.Cart; ListBox1.Items.Clear; for i:=0 to frmMain.Cart.ColumnCount-1 do begin dc := frmMain.Cart.Columns[i]; s := dc.name; ListBox1.Items.Add(s); with Grid1.Columns.Add do DataColumn := s; end; end; Steve |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |