Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 14 of 14 total
Thread manually loading data into a grid
Wed, Jun 18 2014 4:11 AMPermanent Link

Matthew Jones

Stephen Barker wrote:

> And how do I refresh the grid to show the field content and column
> headings?

The best answer is to have a look at the source to the framework and
the grid. Most things are covered I find, but the source often reveals
how you actually acheive it. Obviously something must trigger the
rebuild.

You can also modify the source if you want, though you probably have to
change the permissions on the directory, and you have to reload the IDE
if you change it as it is cached. But that has allowed me to add stuff
to get me over a hurdle until I can ask Tim for an official mechanism,
if there isn't already (which I usually find there is).

--

Matthew Jones
Wed, Jun 18 2014 7:54 AMPermanent Link

Walter Matte

Tactical Business Corporation



I just did a test - in design time all the columns are added to the grid, but if you code runtime, you have to do the work....  Adding the columns to the grid and setting the column properties.

Walter
Wed, Jun 18 2014 8:46 AMPermanent Link

Walter Matte

Tactical Business Corporation

Here is a function to set the grid columns from dataset...

The "Best Fit Width" could be greatly improved....

Walter

procedure MakeGridColumns(grd : TGrid; data : TDataSet);
var
 i, totwidth, wid, widdif : integer;
begin
 totwidth := 0;

 for i := 0 to data.ColumnCount - 1 do     
 begin
   if (data.columns[i].length < 10) and (length(data.columns[i].name) < 10) then  
     totwidth := totwidth + 10
   else if data.columns[i].length > length(data.columns[i].name) then  
     totwidth := totwidth + data.columns[i].length
   else
     totwidth := totwidth + length(data.columns[i].name);
 end;

 if totwidth > grd.width then
   widdif := totwidth - grd.width
 else
   widdif := grd.width - totwidth;

 grd.Dataset := nil;
 grd.Columns.Clear;
 grd.Dataset := data;
 for i := 0 to data.ColumnCount - 1 do
 begin
   with grd.Columns.Add do
   begin
     DataColumn := data.columns[i].name;

     Caption    := data.columns[i].name;

     if (data.columns[i].length < 10) and (length(data.columns[i].name) < 10) then
       wid := 10
     else if data.columns[i].length > length(data.columns[i].name) then
       wid := data.columns[i].length
     else
       wid := length(data.columns[i].name);

     if widdif = 0 then
     begin
       width := trunc(wid);
     end
     else if totwidth > grd.width then
     begin
       wid := wid - trunc(widdif  * (wid / totwidth));
       width := trunc(wid);
     end
     else
     begin
       wid := wid + trunc(widdif  * (wid / totwidth));
       width := trunc(wid);
     end;

     if data.columns[i].datatype = dtBoolean then
       ControlType := ctCheckBox
     else
       ControlType := ctEdit;
   end;
 end;
end;
Tue, Aug 19 2014 7:58 PMPermanent Link

Stephen Barker

In case anyone else was having trouble with the LogOutput procedure, I finally found the issue I was having. There is an optional second parameter, LogURL, which needs to be specified it seems if you use anything other than port 80 for your web server, e.g.

 LogOutput('h: '+IntToStr(pnlHeader.Height), 'http://localhost:81/log');

cheers,
Steve




Chris Holland wrote:

Did you have the Message Pane open (View -> Messages from menu)
Or else you will not see them.

Chris Holland

>
> Anyone got any ideas why the LogOutput isn't working?
>
> Steve
>
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image