Updating a IWGrid in a Async event breaks subsequent Async calls
7/29/2009
Bug Description: If you have a IWGrid and some controls (like TIWButtons) assigned to its cells and these controls have assigned Async calls, all these events are not triggered but the first one only, if your Async call updates the IWGrid contents: procedure TIWForm1.AsyncClick(Sender: TObject; EventParams: TStringList); var ACell: TIWGridCell; begin if Sender is TIWButton then begin ACell := IWGrid1.Cell[TIWButton(Sender).Tag, 1]; ACell.Text := TimeToStr(Time); // this line will cause the problem end; end;
Affected Browsers: All Workaround: - Don't use Async events on controls assigned to IWGrid cells
- Use IWControls within the Grid cells to show some info, instead of updating the Grid contents. The sample code below creates IWLabels and IWButtons and assign these controls to the Grid cells.
procedure TIWForm1.IWGrid1RenderCell(ACell: TIWGridCell; const ARow, AColumn: Integer); begin if AColumn = 2 then begin if not Assigned(ACell.Control) then begin ACell.Control := TIWButton.Create(Self); TIWButton(ACell.Control).Caption := 'A Button'; TIWButton(ACell.Control).OnAsyncClick := AsyncClick; TIWButton(ACell.Control).Tag := ARow; end; end; if AColumn = 0 then begin if not Assigned(ACell.Control) then begin ACell.Control := TIWLabel.Create(Self); TIWLabel(ACell.Control).Caption := 'This is a TIWLabel'; TIWLabel(ACell.Control).Tag := ARow; end; end; end;
Updates will work as the IWGrid is not updated, but the controls within it.
procedure TIWForm1.AsyncClick(Sender: TObject; EventParams: TStringList); var ACell: TIWGridCell; begin if Sender is TIWButton then begin ACell := IWGrid1.Cell[TIWButton(Sender).Tag, 0]; TIWLabel(ACell.Control).Caption := TimeToStr(Time); end; end;
<<
Previous Entry Next Entry
>>
|