CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

CGJQGrid: How to determine selected row(s)

by ScottWGast » 19 Sep 2012 15:32

Hey guys!
So... I've looked at all the properties and the docs, but I cannot seem to figure out how to determine which row(s) are selected.
Point me in the right direction?
Thanks :)
Scott
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by Jorge Sousa » 19 Sep 2012 15:43

Hi Scott

It's JQGridOptions.SelRow

And you're right, it's not yet in documentation,
We must recreate the CHM again, it's produced automatically reading source code summary tags.

Regards

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

by ScottWGast » 19 Sep 2012 15:55

JQGridOptions.SelRow returns the last row selected, not the list of selected rows when mulit-select option is True;
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by Jorge Sousa » 19 Sep 2012 17:31

o sorry

For now you've to set a BrowserParam in the event you need to get

// FormCreate for instance
BrowserParam.BrowserServer:= 'SelRows';
BrowserParam.BrowserScript:= Grid1.JQGridOptions.jsGetSelArrrow; // The name is strange but is the original one

in the event you will receive AParams.Values['SelRows'] in a json format, array of rowids selected ["xyz","abc","etc"]

to work with json in Delphi we've choosen SuperObject @ http://www.progdigy.com/?page_id=6

uses
IWCGJSSuperObject;

procedure TframeMAIN_DIENSTE.IWCGJQGridJQGridCustomButtons0ClickButton(
Sender: TObject; AParams: TStringList);
var
SelRows: ISuperObject;
i: Integer;
RowId: string;
begin
SelRows:= SO(AParams.Values['SelRows']);
if not SelRows.IsType(stArray) then Exit;
for i:= 0 to SelRows.AsArray.Length-1 do
begin
RowId:= SelRows.AsArray.S[i];
end;
end;

A new property JQGridOptions.SelRows will be added soon, to perform this automaticallly

Regards

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

by ScottWGast » 19 Sep 2012 19:08

Thanks for the interim solution! I look forward to the .SelRows property :)

One question: Do I have to set BrowserParam properties on each of the the _specific_ custom button click events? (I have up to 8 buttons that need to utilize the list of selected rows) or is there a way to set BrowserParam properties some place else and have the 'SelRows' property available in any/all of the button click events?

Best,
Scott
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by Jorge Sousa » 19 Sep 2012 19:15

Hi Scott

Yes, for know, and unfortunatelly, while we don't come up with SelRows prop you have to add BrowserParams in each button OnClick

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

by ScottWGast » 19 Sep 2012 19:19

Oh, hey... no worries! I appreciate the info :) I just didn't want to add SelRows to each OnClick if I didn't have to :)
sg
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by seanwebb » 19 Sep 2012 19:34

Hey Scott,
just create one procedure to set the params and call that from all buttons.
you can then remove when the next release comes out.
That's what i did originally when selrow was only available as a param
seanwebb
 
Posts: 50
Joined: 22 May 2012 11:12

by ScottWGast » 19 Sep 2012 20:02

So you can set the params from inside the OnClick event... the params don't have to be set before the OnClick event fires?

I've added some simple code to the form OnCreate:
for i := 0 to Self.gridJQuery1.JQGridCustomButtons.Count - 1 do
begin
browserParam := Self.gridJQuery1.JQGridCustomButtons[i].OnClickButton.BrowserParams.Add;
browserParam.ServerName := 'SelRows';
browserParam.BrowserScript := Self.gridJQuery1.JQGridOptions.jsGetSelArrrow;
end;
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by seanwebb » 20 Sep 2012 07:18

no , i meant call a procedure from within the oncreate
procedure AddSelRowsGridParamsToButton(oGrid:TIWCGJQGrid;oBtn:TIWCGJQButton)
The procedure then can ref from other grids in other units too.....
Then its a 1 lines in each grid oncreate that can be search for and removed after they release that fix
seanwebb
 
Posts: 50
Joined: 22 May 2012 11:12

Next

Return to JQGrid

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Contact Us.