Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
App Crash with IWDBGrid and bootstrap
#1
I have been butting my head against a wall for a couple of days so I thought I would post my issue here in hopes someone else has run into this.  I have latest Delphi 10.2 and Intraweb 15 installed with the bootstrap components from IW.   I have a number of forms in my application but the issue is the one with the interactive DB Grid.  All was working fine until I added in the resource maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css and other supporting libraries.  All a sudden, my grid lost its title centering and padding which I solved with custom CSS.  

I am using bootstrap for a star rating plugin that I display in the grid to show the rating of a particular customer entity.  I have a number of filters in combo boxes on the screen that I have click events for all a SQL Sever sproc that feeds in the value selected to then return the result set that is fed into the grid.  The starting point is no data and the user has to choose at least one filter to start seeing data.

So here is the weird stuff.  When the form first loads, I can select a filter and the first set of data loads perfectly.  I try to select the second filter and WHAM the application crashes with access to an unknown memory location (Access violation at address 000000000040E045 in module 'OwnerBuilder.exe'. Read of address FFFFFFFFFFFFFFFF).  If I try to refresh the browser I also receive the crash.  So any time there is a data refresh and the DBGrid tries to render again, this is where I receive my crash.

I changed the filters to async clicks and then I go to another form with a button click that displays the details for that customer and the data is totally fine under the hood and when I return to the main form with TfMainForm.Create(WebApplication).Show, the grid is rendered fine with the latest filter change I had completed. So the issue is when the grid is attempting to render when the dataset has changed when I get the crash.  So the workaround is to set the filter(s) async and then go to another form and return and all is well which of course is no good for production use and is just for testing to isolate the issue.

To add clarity, I only am using the bootstrap for the graphic star display inside the grid using a CSS class off that specific control in that 1 cell.  The grid is 100% native IWDBGrid component.

If anyone has any ideas or comments I would be very appreciative.

Cheers.
bob
Reply
#2
More on this. I have another form that I added a grid and all was fine until I added this jquery component in the grid and now this is bombing when rendering. More information since I have isolated what exactly is bombing now is I added a editbox control for the column in the GridRenderCell that has its CSS set to the jquery which initial renders 100% but each render after that causes the crash.

jquery init in form create:
JQueryStarReadOnlyGrid.OnReady.Text := '$(''.RatingGridReadOnly'').rating({''displayOnly'':true,''showClear'':false,''size'':''sm'',''step'':.1,';
JQueryStarReadOnlyGrid.OnReady.Text := JQueryStarReadOnlyGrid.OnReady.Text + '''starCaptions'':{0.5: ''.5 Star'',1: ''1 Star'',1.5: ''1.5 Star'',2: ''2 Stars'',2.5: ''2.5 Stars'',3: ''3 Stars'',3.5: ''3.5 Stars'',4: ''4 Stars'',4.5: ''4.5 Stars'',5: ''5 Stars''}})';

rendercell:
if (ARow > 0) and (AColumn = 1) and (not Assigned(ACell.Control)) then
begin
ACell.Control := TIWEdit.Create(Self);
with TIWEdit(ACell.Control) do
begin
Name := self.Name + 'RowSelector' + inttostr(ARow);
Tag := ARow;
Caption := 'Rating';
Text := UserSession.spRenderGrid.FieldByName('Star_Rating_Text').AsString;
css := 'RatingGridReadOnly';
end;
end;

The render has no jquery init so maybe that is the issue. that is the only difference between the create and render that I can think of. I comment out the css init though and there is still the crash. only when I comment out the whole code block so there is no control added dynamically does this start working. So perhaps the issue is in the addition of the control dynamically and nothing to do with the jquery or bootstrap. I am going to try to use a different controls or settings there without the jquery for now to see if I can see how things go.
Reply
#3
OK, figured it out. Only a matter of time when I isolated the exact thing causing the issue. Too many changes at one time took a while to nail. When a control is dynamically added in the IWDBGrid cell, it takes care of the name to ensure it is unique and there is no access allowed to it from what I can see. So with me touching it, this caused an instability inside IntraWeb. So when I remove the line "Name := self.Name + 'RowSelector' + inttostr(ARow);" so the name is no longer touched all works perfectly and my bootstrap jquery star rating displays perfectly and I can work the grid with my filters just like I was able to before.

The place I copied the base template code from must have either never worked in the first place or it was from an old version of IW that perhaps allowed this. If anyone has anything to add to this for someone else adding a control to a grid there then is one less of an issue someone may run into in future.

May your new years be bless in perfection stability universal abundance.
Cheers!
Reply
#4
Thanks for the follow up and glad you sorted it.
Reply
#5
Where did you get the "template" code from?

Can you recreate this issue in a small test case?

The point here is: IntraWeb might (actually will) change the parent of such controls at runtime when rendering the page. If you touch this yourself, this might cause lots of problems.
Reply
#6
(01-11-2019, 09:44 AM)Alexandre Machado Wrote: Where did you get the "template" code from?

Can you recreate this issue in a small test case?

The point here is: IntraWeb might (actually will) change the parent of such controls at runtime when rendering the page. If you touch this yourself, this might cause lots of problems.

Sorry for the long delay in response.  I missed the email that on this thread somehow.  I found on a forum somewhere when I was looking to try to get a mouse select for a row in a DBGrid and adding a custom checkbox column.  So the checkbox was getting created at run time and setting the control name which turned out to be a no no.  I cannot remember where I found the snip of code.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)