Columns wwDataGrid
Hello,
I have a wwDataGrid that has som predefined columns. If data is retrieved from the server (this is a multitier app) the first time there is no problem. Even if some columns are not available in the fetched data. They are not shown. When I retrieve data a second time from the server and a column that wasn't available in the first fetch, now is in the data, is not shown in the grid. This is because its visible property is false. When I want to change it to true an access violation is shown.
Any idea what i need to do to make this approach work?
Thanks,
Erik
-
I encounter the same result but in a slightly different situation, but I think that my work-around might work for you.
When I configure the grid in the IDE, the datasource has references to all of the fields that the grid can display.
At run-time, I make sure the queries also include all of those fields. Then, I selectively add to the grid only those fields that are desired at that time.
Maybe the following code will give you an idea that works for you.
grdAttachment.Selected.Clear;
if UserCanSeeAttachmentLocation then
begin
grdAttachment.Selected.Add('file_drive'#9'4'#9'Drive~letter'#9'F');
grdAttachment.Selected.Add('file_server'#9'11'#9'Server~name'#9'F');
grdAttachment.Selected.Add('file_path'#9'22'#9'File path'#9'F');
grdAttachment.Selected.Add('file_name'#9'35'#9'File name'#9'F');
grdAttachment.Selected.Add('original_path_and_filename'#9'50'#9'Original path and filename~(for the user who attached the file)'#9'F');
grdAttachment.FixedCols := 4;
pnlAttachmentLocation.Visible := True;
end
else
begin
grdAttachment.Selected.Add('file_name'#9'60'#9'File name'#9'F');
grdAttachment.Selected.Add('original_path_and_filename'#9'40'#9'Original path and filename~(for the user who attached the file)'#9'F');
grdAttachment.FixedCols := 1;
pnlAttachmentLocation.Visible := False;
end;
grdAttachment.Selected.Add('remark'#9'16'#9'Remark'#9'F');
grdAttachment.Selected.Add('updated_by_logon_name'#9'12'#9'Updated by'#9'F');
grdAttachment.Selected.Add('updated_on'#9'18'#9'Updated~on'#9'F');
grdAttachment.Selected.Add('created_by_logon_name'#9'12'#9'Created by'#9'F');
grdAttachment.Selected.Add('created_on'#9'18'#9'Created~on'#9'F');
grdAttachment.Selected.Add('performance_test_request_id'#9'6'#9'Req~ID'#9'F');
grdAttachment.Selected.Add('inactive_flag'#9'6'#9'Inactive'#9'F');
grdAttachment.Selected.Add('inactive_on'#9'11'#9'Inactive~on'#9'F');
grdAttachment.Selected.Add('id'#9'6'#9'ID'#9'F');
grdAttachment.ApplySelected; -
Thanks for this work around. It'll indeed work when you clear the columns and then recreate them but why is it working whithout this when you open the datasource the first time and not the second time? I think Roy can help us to have it working in the future withhout this workaround.
-
I think Michael is using InfoPower, so his solution would not apply to FirePower's TwwDataGrid. I'm also not sure how to reproduce your problem. I don't know if it would help, but you could try calling the method Columns.BeginUpdate before you change your visible property, and then Columns.EndUpdate afterwards.
Also if you can create a reproducable case you can email me that would help me figure out your issue.
Please sign in to leave a comment.
Comments
4 comments