I've tried the grid.OnAfterRenderHTML, but when I check .SelRows, it returns the number of rows that were selected _before_ I refreshed the dataset.
Am I barking up the wrong tree?
Scott
UPDATE:
As it turns out, the only item that is not correct is the Grid.JQGridOptions.Caption. I set the caption to show the number of rows and the number of selected rows... _after_ I open the dataset. The number of rows is correct, but the number of "Selected rows" shows the number of rows that were selected before I closed the dataset, changed the parameters and the re-opened the dataset.
Also, based on criteria, I either show the columns "Sent Date", "Received Date" or both. (See LoadEmailGridData, below). These columns _always_ display, it doesn't matter if I set their .Viewable property to False.
- Code: Select all
procedure TframeEmailClient.LoadEmailGridData;
var
strSQL: String;
begin
if UserSession.OpenDBConnection then
begin
if Self.adoEmailList.Active then
Self.adoEmailList.Close;
if Self.FSelectedFolderID = Self.FSentFolderID then
begin
strSQL := 'SELECT * FROM email WHERE folder_id = :FolderID ORDER BY sent_date DESC';
Self.gridEmail.JQGridColumns.ItemsByName['sent_date'].Viewable := True;
Self.gridEmail.JQGridColumns.ItemsByName['received_date'].Viewable := False;
end
else if Self.FSelectedFolderID = Self.FInboxFolderID then
begin
strSQL := 'SELECT * FROM email WHERE folder_id = :FolderID ORDER BY received_date DESC';
Self.gridEmail.JQGridColumns.ItemsByName['sent_date'].Viewable := False;
Self.gridEmail.JQGridColumns.ItemsByName['received_date'].Viewable := True;
end
else
begin
strSQL := 'SELECT * FROM email WHERE folder_id = :FolderID ORDER BY received_date DESC';
Self.gridEmail.JQGridColumns.ItemsByName['sent_date'].Viewable := True;
Self.gridEmail.JQGridColumns.ItemsByName['received_date'].Viewable := True;
end;
Self.adoEmailList.CommandText := strSQL;
Self.adoEmailList.Parameters.ParamByName('FolderID').Value := Self.FSelectedFolderID;
Self.adoEmailList.Open;
if Self.adoEmailList.RecordCount > 400 then
begin
Self.gridEmail.JQGridOptions.RowNum := 250;
Self.gridEmail.JQGridOptions.PagerVisible := True;
Self.gridEmail.JQGridOptions.Scroll := False;
end
else
begin
Self.gridEmail.JQGridOptions.RowNum := Self.adoEmailList.RecordCount;
Self.gridEmail.JQGridOptions.PagerVisible := False;
Self.gridEmail.JQGridOptions.Scroll := True;
end;
Self.SetGridTitle();
end;
end;
procedure TframeEmailClient.SetGridTitle(IsRowSelected: Boolean = True);
var
strCaption: String;
iCount: Integer;
begin
strCaption := S2Snax.IntegerToString(Self.adoEmailList.RecordCount) + ' Email' + S2Snax.Iif(Self.adoEmailList.RecordCount>1,'s','') + ' (' + Self.FSelectedFolderName + ')';
iCount := Length(Self.gridEmail.JQGridOptions.SelRows);
if (iCount > 0) and IsRowSelected then
strCaption := strCaption + ' (' + IntToStr(iCount) + ' Rows Selected)';
Self.gridEmail.JQGridOptions.Caption := strCaption;
end;