unit GridSort;
{PUBDIST}

interface

uses
  IWAppForm, IWApplication, IWTypes, Classes, Controls, IWControl,
  IWWebGrid, IWAdvWebGrid, IWCompButton, IWCompLabel, IWBaseControl,
  LeftFrame, Forms, TopFrame, IWVCLBaseControl, IWBaseHTMLControl;

type
  TformGridSort = class(TIWAppForm)
    TIWAdvWebGrid1: TTIWAdvWebGrid;
    IWButton1: TIWButton;
    IWButton2: TIWButton;
    IWLabel1: TIWLabel;
    FrameTopFrame1: TFrameTopFrame;
    FrameLeftFrame1: TFrameLeftFrame;
    procedure IWAppFormCreate(Sender: TObject);
    procedure IWButton1Click(Sender: TObject);
    procedure TIWAdvWebGrid1CellClick(Sender: TObject; RowIndex,
      ColumnIndex: Integer);
    procedure TIWAdvWebGrid1ColumnHeaderClick(Sender: TObject;
      ColumnIndex: Integer);
    procedure IWButton2Click(Sender: TObject);
  public

  end;

implementation
{$R *.dfm}

uses
  ServerController;

procedure TformGridSort.IWAppFormCreate(Sender: TObject);
begin
  with tiwadvwebgrid1 do
  begin
    cells[1,0] := 'BMW';
    cells[2,0] := '330ci';
    cells[3,0] := '289';
    cells[4,0] := '1/8/2000';
    cells[5,0] := '45000';

    cells[1,1] := 'Mercedes';
    cells[2,1] := 'SLK 200';
    cells[3,1] := '164';
    cells[4,1] := '5/4/1996';
    cells[5,1] := '39000';

    cells[1,2] := 'Audi';
    cells[2,2] := 'TT';
    cells[3,2] := '225';
    cells[4,2] := '10/10/1999';
    cells[5,2] := '32000';

    cells[1,3] := 'Ferrari';
    cells[2,3] := 'F355';
    cells[3,3] := '476';
    cells[4,3] := '1/1/1995';
    cells[5,3] := '132000';

    cells[1,4] := 'Porsche';
    cells[2,4] := '911';
    cells[3,4] := '380';
    cells[4,4] := '1/10/1997';
    cells[5,4] := '75000';

    cells[1,5] := 'Mercedes';
    cells[2,5] := 'SLR';
    cells[3,5] := '576';
    cells[4,5] := '1/1/2003';
    cells[5,5] := '250000';

    cells[1,6] := 'Lotus';
    cells[2,6] := 'Elise';
    cells[3,6] := '122';
    cells[4,6] := '5/7/1998';
    cells[5,6] := '41000';

    cells[1,7] := 'Wiessman';
    cells[2,7] := 'MF';
    cells[3,7] := '193';
    cells[4,7] := '1/6/1997';
    cells[5,7] := '60000';

    cells[1,8] := 'Maserati';
    cells[2,8] := '4200 GT';
    cells[3,8] := '390';
    cells[4,8] := '25/12/2000';
    cells[5,8] := '85000';

    cells[1,9] := 'Lamborghini';
    cells[2,9] := 'Murcielago';
    cells[3,9] := '580';
    cells[4,9] := '16/3/2002';
    cells[5,9] := '224000';

  end;
end;

procedure TformGridSort.IWButton1Click(Sender: TObject);
begin
  if tiwadvwebgrid1.State = gsEdit then
  begin
    tiwadvwebgrid1.Post;
    iwbutton1.Caption := 'Edit';
  end
  else
  begin
    tiwadvwebgrid1.ActiveColumn := 5;
    tiwadvwebgrid1.Edit;
    iwbutton1.Caption := 'Update';
  end;
end;

procedure TformGridSort.TIWAdvWebGrid1CellClick(Sender: TObject; RowIndex,
  ColumnIndex: Integer);
begin
  tiwadvwebgrid1.ActiveRow := RowIndex + tiwadvwebgrid1.RowOffset;
  tiwadvwebgrid1.ActiveColumn := 5;
  tiwadvwebgrid1.Edit;
end;

procedure TformGridSort.TIWAdvWebGrid1ColumnHeaderClick(Sender: TObject;
  ColumnIndex: Integer);
begin
  TIWadvWebGrid1.SortSettings.Column := ColumnIndex;
  TIWadvWebGrid1.QSort;
end;

procedure TformGridSort.IWButton2Click(Sender: TObject);
begin
  tiwadvwebgrid1.Columns[1].Visible := not tiwadvwebgrid1.Columns[1].Visible;
end;

initialization
  TformGridSort.SetAsMainForm;

end.
