Jump to content

Get the string value of the StringGrid


eduardosuruagy

Recommended Posts

51 minutes ago, eduardosuruagy said:

What I want is to double click on the column "Col3" and get the description of the column that would be "Col3" if I give two clicks on another column would be the same, would take the description... 

One possible solution

1. function headerclick:

function headerclick(ct, column, e, t, eOpts) 
{
    var timeNow = (new Date()).getTime();

    if (this.lastClicked) {
        if (timeNow > (this.lastClicked + 200)) {

        } else {
            ajaxRequest(this, "columndblclick", ["columntext=" + column.text, "columnindx=" + column.dataIndex]);

        }
    }

    this.lastClicked = timeNow;
}

2. OnAjaxEvent:

procedure TMainForm.UniStringGrid1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = 'columndblclick' then
  begin
    ShowMessage(Params.Values['columntext'] + ',' + Params.Values['columnindx']);
  end;

end;

 

Link to comment
Share on other sites

Just use the example that comes in the unigui installation folder, if you look at the image I used the mdemo example.

Another thing, I have the first 3 fixed columns, the first and second I quertia that had the width of 30 centralized and the third of the size of 250 aligned to the left and the other columns that were added dynamically had the width of centralized 30 How do I do this?
In the ClientEvents.ExtEvents.reconfigure I put the code below, but it did not work:

 

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
  columns[0].maxWidth = 30;
  columns[0].rdonly   = true;
  columns[0].align    = 'center';
  
  columns[1].maxWidth = 30;
  columns[1].rdonly   = true;
  columns[1].align    = 'center';

  columns[2].maxWidth = 250;
  columns[2].rdonly   = true;

  columns.forEach(function(el){el.flex=1});

/*  
  for (i = sender.fxCols; i < columns.length; i++) 
  {
    if (i > 2)
    {
      columns.rdonly   = true;
      columns.maxWidth = 70;
      columns.align    = 'center';
    }  
  }
*/    

 

Please help me, I've been trying to solve this for days and I can not

Link to comment
Share on other sites

I think the problem is that this example already the columns are already fixed and in my I include them automatically, if you take the example of unit GridsStringGrid that is in the project mmdemo and put 3 fixed columns you will see that the event headerclick he does not shoot.

As I told you, I do the grid automatically, they are 3 fixed columns and the rest I am adding as the user wants.

What tool do you use to record this video?

Link to comment
Share on other sites

28 minutes ago, eduardosuruagy said:

I want to click on the column and put the column rows into editing, but only one column can be edited at a time and when I click again on the column I remove the edit from the rows of it, I tried to do that.

Does your code work in VCL? Sorry, can you also make a simple testcase for VCL?

Link to comment
Share on other sites

  • 4 years later...
On 2/26/2019 at 2:44 AM, Sherzod said:

One possible solution

1. function headerclick:

function headerclick(ct, column, e, t, eOpts) 
{
    var timeNow = (new Date()).getTime();

    if (this.lastClicked) {
        if (timeNow > (this.lastClicked + 200)) {

        } else {
            ajaxRequest(this, "columndblclick", ["columntext=" + column.text, "columnindx=" + column.dataIndex]);

        }
    }

    this.lastClicked = timeNow;
}

2. OnAjaxEvent:

procedure TMainForm.UniStringGrid1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = 'columndblclick' then
  begin
    ShowMessage(Params.Values['columntext'] + ',' + Params.Values['columnindx']);
  end;

end;

 

EventName = columndblclick  not fire.

StringGrid2.zip

Link to comment
Share on other sites

  • 2 weeks later...

OnMouseDown...Y<=30 ... determine is ColumnTitle Click.
How to translate X to Grid ColumnIndex?

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
      columns.forEach(function(col) {
        if (col.titleEl) {
            col.titleEl.on('click', function() {
                ajaxRequest(sender, 'headerclick', ['colIndx=' + col.dataIndex]);
            })
        }
    });
}

 

procedure Grid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin

  if EventName = 'headerclick' then
    begin
      var oColumnIndex:= StrToInt(Params.Values['colIndx']);
      if oColumnIndex>=0 then

         ...

   end

end;
Work Perfect.

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...