Jump to content

Recommended Posts

Posted

Hi all, I'm trying to get all visible columns at runtime (in web mode), but if I try to do it using the property Visible of a column, it doesn't work. If I click on the column title to hide or show a column, as shown in picture attached.

 

post-1040-0-21446700-1381480976_thumb.jpg

 

the column is hidden, but the property Visible of that colum remain true. How can I retrieve all visible columns at a given time? The code I write is this, but with the property Visible doesn't work:

 

procedure TmailsFrame.getVisibleColumns(var slColumns: TStringList);
var
  iCount: Integer;
begin
  try
    slColumns.Clear;
    for iCount := 0 to UniDBGrid1.Columns.Count - 1 do
    begin
      if (UniDBGrid1.Columns.Items[iCount].Visible = true) then
        slColumns.Add(UniDBGrid1.Columns.Items[iCount].Title.Caption);
    end;
  except
    on e: Exception do
      ShowMessage(e.Message);
  end;
end;

 

Posted

Hi MarcoRu.

 

Try this:

uses ... UniGUIApplication ...
procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  
  UniSession.AddJS('var strList = ""; Ext.each('+UniDBGrid1.JSName+'.columns, function(col, index) {if (!col.hidden){if (strList === ""){strList = col.text}{strList = strList + "," + col.text}}}); ajaxRequest ('+UniButton1.JSName+',''getVisibleList'', [''List=''+strList]);');

end;
procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TStrings);
begin  
   if (EventName = 'getVisibleList') Then begin
    //Params.Values['List'] - Returns a string separated by commas ...   
    ShowMessage(Params.Values['List']);  
   end;
end;

Sincerely ...

Posted
Hi, 
 
I had the same problem.
I do not know if you can help :
 
Sample Code .... 
 
Procedure  TFXXX.XReadColumnsHidden;
 
Var Xread : String ;
begin
 
  Xread := 'Xreadvisible' ;
  unisession.addjs('var cols=new Array(' +inttostr( grid.Columns.Count)+ ');' +
 
                   'for (i=0;i<cols.length;i++){'+
                   'cols=' +  grid.Jsname   +'.columns.hidden;}'+
                   'var str=cols.toString();' +
                   'ajaxRequest(' + grid.jsname + ',' + '''' + Xread + '''' +   ' , ["ofs="+str])');
end;
 
 
procedure TFXXX.gridAjaxEvent(Sender: TComponent; EventName: string;
  Params: TStrings);
 
  StrVisible  : String ;
  Ts          : Tstrings ;
begin
   
   if SameText(Eventname,'XreadVisble') then begin
      StrVisible := Params.Values['ofs']; 
     //    Code Sample
     Ts := Tstringlist.Create ;
     Ts.Delimiter := ',' ;
     Ts.DelimitedText := StrVisible ;
     Code Sample
     for I  := 0 to  grid.Columns.count - 1 do begin
       //  Your code ..................  
     end;
     ts.free ;
     //    Code Sample
 
   end ;  
 
end;

 

 
 
 
regards

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...