Jump to content

How to Set(Change) Grid Current Column/Cell ?


Anachronox

Recommended Posts

Since there's no SelectedIndex property on TUniDBGrid, how to change active (selected) grid column (cell) in runtime ?

 

I tried to call ExtJS tweak:

 

UniSession.AddJS('Form.Grid.getView().focusCell(3,3)');

 

but without success (no error, no action).

 

Is there ANY solution how to control grid active column ?

 

(Active Row is DataSet Current Record).

 

Thanks a lot.

 

Link to comment
Share on other sites

You can create a inherited component, i.e. TUniExDBGrid = class( TUniDBGrid ); add one property "property Col: Integer read GetCol write SetCol;" and in implementation add below code:


  TUniExDBGrid = class( TUniDBGrid )

  private
    function  GetCol: Integer;
    procedure SetCol(Value: Integer);

  published
    property Col: Integer read GetCol write SetCol;
 
Implementation

function TUniExDBGrid.GetCol: Integer; 
begin 
  Result := CurrCol-1; {-1 for CurrCol} 
end; 

procedure TUniExDBGrid.SetCol(Value: Integer); 
begin 
  CurrCol:=Value+1; {+1 for CurrCol} 
end; 

 

It works for me, let me know whether it works for you or not.

  • Upvote 2
Link to comment
Share on other sites

One more option is using Hack

 

unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,  Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses...
.
.
type THackGrid = class(TUniDBGrid);
type
  TMainForm = class(TUniForm)
    Grid1: TUniDBGrid;
.
.
  private
    { Private declarations }
  public
    { Public declarations }

implementation

procedure TMainForm.BitBtnmovecolClick(Sender: TObject);
begin
   THackGrid(Grid1).CurrCol :=  newindex ;  // Set the required columindex
end;

  • Upvote 1
Link to comment
Share on other sites

  • 5 years later...

What an odd property (CurrCol) to be protected. Has anything changed in this respect in the past 5 years ?
I'm coming towards the end of my UniGUI evaluation - just the Grid to test and I'm finding it missing a lot of functionality compared to thge VCL grids I'm used to. Hopefully just the learning curve, rather than missing features.

Link to comment
Share on other sites

  • Administrators

What an odd property (CurrCol) to be protected. Has anything changed in this respect in the past 5 years ?

I'm coming towards the end of my UniGUI evaluation - just the Grid to test and I'm finding it missing a lot of functionality compared to thge VCL grids I'm used to. Hopefully just the learning curve, rather than missing features.

 

Hi,

 

What are those functions that you have found missing?

If you are referring to standard VCL.TDBGrid, uniGUI already has a lot far more features compared with it.

Link to comment
Share on other sites

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...