CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Using gcfControl on IWCGJQGrid

by rhazell43 » 10 Oct 2013 17:22

Hello,

When using gcfControl it would appear IWCGJQGrid1.JQGridOptions.SelRow is set AFTER the event for the embedded control is fired, making it, well... virtually unusable.

The code below results in display the of IWCGJQGrid1.JQGridOptions.SelRow from the previous click.

Code: Select all
  iCol:= IWCGJQGrid1.JQGridOptions.ColModel.Add;
  iCol.Name := 'Select';
  iCol.Caption := '';
  iCol.Editable := False;
  iCol.Sortable := False;
  iCol.Width := 50;
  iCol.Align:= gaCenter;
  iCol.Sortable := False;
  iCol.Formatter := gcfControl;
  iCol.FormatOptionsControl.ControlTemplate := btnSelect;


procedure TformSelectProgram.btnSelectJQButtonOptionsClick(Sender: TObject;
  AParams: TStringList);
begin
  WebApplication.ShowMessage('Button click event: '+IWCGJQGrid1.JQGridOptions.SelRow);
end;


Thanks
rhazell43
 
Posts: 80
Joined: 29 Apr 2013 08:27

by Jorge Sousa » 10 Oct 2013 18:24

Then don't use it
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by rhazell43 » 10 Oct 2013 21:33

Please don't take my report as hollow criticism ;) I'm a very big fan of your components... best thing I've seen for a long time breathing new life into Intraweb and therefore Delphi.

I question the purpose of having a button on each line if there's no way to now which line was clicked (which is what I really need)... perhaps I'm going about the wrong way?

Any advice would be greatly appreciated.

Thanks Rick.

PS many reports recently because I'm actively develpoing a rather large real-life application. I hope my reports can help make your great product even greater!!
rhazell43
 
Posts: 80
Joined: 29 Apr 2013 08:27

by Jorge Sousa » 10 Oct 2013 23:04

Hi Rick

Now you're talking :)

The value of SelRow is not updated, because the row isn't selected at all.

With this formatter: gcfControl, the control template is responsible for selecting the row.

If you use FormatOptions.CreateCellsOnRender = False (default), you must use Col.OnUpdateControl
if .CreateCellsOnRender = True (faster), you must use Col.OnUpdateCellControl

We are going to prepare a demo to explain how to use it.

Best Regards
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by Jorge Sousa » 11 Oct 2013 17:41

Hi Rick

Considering IWCGJQGrid the grid's name and IWCGJQButton1 the name if the button used as ControlTemplate:

Using Col.FormatOptionsControl.CreateCellsOnRender = False (default value)

Trap Col.OnUpdateControl event and do

Code: Select all
procedure TIWForm3.TIWCGJQGridOptionsColModel9UpdateControl(Sender: TObject;
  ACol: TIWCGJQGridCol; const ARowId, ACellValue: string);
begin
  IWCGJQButton1.Tag:= IWCGJQGrid.RowIndexForRowId[ARowId];
end;



If Col.FormatOptionsControl.CreateCellsOnRender = True (recommended)

Trap Col.OnUpdateCellControl and do

Code: Select all
procedure TIWForm3.TIWCGJQGridOptionsColModel9UpdateCellControl(Sender: TObject;
  ACol: TIWCGJQGridCol; AControl: TControl; ARowIdx: Integer; const ARowId,
  ACellValue: string; var AResizeCell: Boolean);
var
  Button: TIWCGJQButton;
begin
  Button:= IWCGJQGrid.FindCellControl(IWCGJQButton1.Name,ACol.Index,ARowIdx) as TIWCGJQButton;
  if Assigned(Button) then
    Button.Tag:= ARowIdx;
end;



Note: In the current version, if FormatOptionsControl.CreateCellsOnlRender = True, the ControlTemplate must be a TIWRegion or TIWCGJQRegion. However this limitation was overseeded in incoming version .3010

In both cases the event handler of IWCGJQButton will have to make the selection:

Code: Select all
procedure TIWForm3.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
var
  Button: TIWCGJQCustomButton;
  RowID: string;
begin
  Button:= (Sender as TIWCGJQButtonOptions).Button;
  RowID:= IWCGJQGrid.RowId[Button.Tag];
  IWCGJQGrid.JQGridOptions.SetSelection(RowID);
end;


Best Regards
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by rhazell43 » 13 Oct 2013 20:14

If Col.FormatOptionsControl.CreateCellsOnRender = True (recommended)


I would have preferred to use this method but doing so, my control wouldn't show io the grid. I used a TIWRegion as the control with a button on it. Maybe this will work when I migrate to the version that doesn't require a region ;)

Using Col.FormatOptionsControl.CreateCellsOnRender = False (default value)


I got this working but I had to change the code slightly (regarding key/ID) perhaps this pertains to me only?

Code: Select all
procedure TformSelectProgram.IWCGJQGrid1OptionsUpdateControl(Sender: TObject;
  ACol: TIWCGJQGridCol; const ARowId, ACellValue: string);
begin
  btnSelect.Tag:= StrToInt(ARowId);
end;


Code: Select all
procedure TformSelectProgram.btnSelectJQButtonOptionsClick(Sender: TObject;
  AParams: TStringList);
var
  Button: TIWCGJQCustomButton;
begin
  Button:= (Sender as TIWCGJQButtonOptions).Button;
  IWCGJQGrid1.JQGridOptions.SetSelection(Button.Tag);
end;


Thanks for your guidance
rhazell43
 
Posts: 80
Joined: 29 Apr 2013 08:27

by Jorge Sousa » 14 Oct 2013 09:53

Hi Rick

I got this working but I had to change the code slightly (regarding key/ID) perhaps this pertains to me only?


Yes not all RowIDs - Keys, can be can converted to Integer

Regards
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by fateh78 » 12 Apr 2017 01:35

PS many reports recently because I'm actively develpoing a rather large real-life application. I hope my reports can help make your great product even greater!!

i did the following to show IWCGJQCheckBoxEx (i named : cbCanUseDataEntry) in a column :

Code: Select all
  fCol.Editable := False;
  fCol.Formatter := gcfControl;
  fCol.FormatOptionsControl.ControlTemplate := cbCanUseDataEntry;
  fCol.FormatOptionsControl.CreateCellsOnRender := False;
  fCol.OnUpdateControl:= TIWCGJQGridDataEntryUpdateControl;


Code: Select all
procedure TUserItemsAccessForm.TIWCGJQGridDataEntryUpdateControl(Sender: TObject; ACol: TIWCGJQGridCol; const ARowId, ACellValue: string);
var       v : Variant;
begin
  //ShowMessage(ACellValue);

  cbCanUseDataEntry.Tag := cxGrid1DBTableView1.RowIndexForRowId[ARowId];
  cbCanUseDataEntry.Caption := ARowId;

  v := cxGrid1DBTableView1.CellValues[ACol.ID, cbCanUseDataEntry.Tag];
  cbCanUseDataEntry.Checked := v = 'T';
end;


i know i can use (fCol.Formatter := gcfCheckBox;), but i made this as test case for using controls in grid.

1- First i thought just giving the IWCGJQCheckBoxEx its DataLink property will be enough, but that did not worked !!!
2- Is this way is correct for using control in grid ??
3- When i check some cells that is not reflected to the dataset, how to do ??

note : please do not say go to documents and demos :cry: :cry:

CheckBoxInGrid.PNG

best regards
You do not have the required permissions to view the files attached to this post.
fateh78
 
Posts: 85
Joined: 16 Mar 2017 21:45

by fateh78 » 12 Apr 2017 01:38

note these 2 lines of code :

v := cxGrid1DBTableView1.CellValues[ACol.ID, cbCanUseDataEntry.Tag];
cbCanUseDataEntry.Checked := v = 'T';

------------------------------------------------------------
Important note : also i found that ACellValue in TIWCGJQGridDataEntryUpdateControl event always null !!!! ???
fateh78
 
Posts: 85
Joined: 16 Mar 2017 21:45

by Alexander Bulei » 13 Apr 2017 09:30

Hi fateh78,

Please send us the simple testcase project.
TIA

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

Next

Return to JQGrid

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.