Jump to content

How to delay stringgrid send event back to server when change select row?


newsanti

Recommended Posts

10 hours ago, newsanti said:

How to delay stringgrid send event back to server when user change selection?  (User scroll with keyboard)

Try this workaround:

function afterrender(sender, eOpts) 
{
    sender.on('keydown', function() {
        if (!sender.getSelectionModel().isSuspended('select')) {
            sender.getSelectionModel().suspendEvent('select')
        }
    });
    sender.on('keyup', function() {
        sender.getSelectionModel().resumeEvent('select');
        sender.getSelectionModel().fireEvent(
            'select', 
            sender.getSelectionModel(), 
            false, 
            sender.getSelectionModel().getCurrentPosition().row, 
            sender.getSelectionModel().getCurrentPosition().column
        )
    });
}

 

  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Sherzod said:
function afterrender(sender, eOpts) 
{
    sender.on('keydown', function() {
        if (!sender.getSelectionModel().isSuspended('select')) {
            sender.getSelectionModel().suspendEvent('select')
        }
    });
    sender.on('keyup', function() {
        sender.getSelectionModel().resumeEvent('select');
        sender.getSelectionModel().fireEvent(
            'select', 
            sender.getSelectionModel(), 
            false, 
            sender.getSelectionModel().getCurrentPosition().row, 
            sender.getSelectionModel().getCurrentPosition().column
        )
    });
}

And it gives some optimization.

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...
On 5/12/2023 at 2:09 PM, Sherzod said:

Try this workaround:

function afterrender(sender, eOpts) 
{
    sender.on('keydown', function() {
        if (!sender.getSelectionModel().isSuspended('select')) {
            sender.getSelectionModel().suspendEvent('select')
        }
    });
    sender.on('keyup', function() {
        sender.getSelectionModel().resumeEvent('select');
        sender.getSelectionModel().fireEvent(
            'select', 
            sender.getSelectionModel(), 
            false, 
            sender.getSelectionModel().getCurrentPosition().row, 
            sender.getSelectionModel().getCurrentPosition().column
        )
    });
}

 

if Grid is Editing Mode...Editing Mode Exist.
How to check Editing Mode in this script?

Link to comment
Share on other sites

  • 4 months later...

Hello, 
I'm trying to apply it, but it doesn't seem to be working for me.
For every keyboard press, it still triggers a HandleEvent.

To be sure, am I applying the workaround in the stringGrid->ClientEvents->ExtEvents->Ext.Grid.Panel->afterrender, right?

I am using D11.3 and v.1.90.0.1567 Complete

 

Link to comment
Share on other sites

23 minutes ago, Sherzod said:

Hello, 

If the stringgrid is in read-only mode, and not related to other controls, and synchronization with the server is not important to you, then I think it is possible to disable these events.

Exactly. I use the stringGrid just to show some data. No editing, no sync.

Link to comment
Share on other sites

7 hours ago, lema said:

Exactly. I use the stringGrid just to show some data. No editing, no sync.

Okay, then try this approach:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSAddListener('viewready', 'function(){this.getSelectionModel().suspendEvent("select")}');
end;

 

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Sherzod said:

Okay, then try this approach:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSAddListener('viewready', 'function(){this.getSelectionModel().suspendEvent("select")}');
end;

 

Yes! Thank you, Master !

Note: It works only when Grid rowselect is NOT enabled.
To cover this case as well -without knowing if it's the correct way-
I changed it to 'suspendEvents(),' and it seems to be working.

UniStringGrid1.JSInterface.JSAddListener('viewready', 'function(){this.getSelectionModel().suspendEvents()}');

 

Link to comment
Share on other sites

Hello,

18 minutes ago, lema said:

Note: It works only when Grid rowselect is NOT enabled.

I couldn't reproduce. Works for me.

19 minutes ago, lema said:

I changed it to 'suspendEvents(),' and it seems to be working.

Yes, this disables all events (this is not recommended).

Link to comment
Share on other sites

20 minutes ago, Sherzod said:

Hello,

I couldn't reproduce. Works for me.

I am testing with the original StringGrid Demo (attached is my test).
The only change I made, is setting the property goRowSelect to True.
The suspendEvent("select") doesn't work with me (v.1.90.0.1567)

Sherzod, I don't want to waste your time, don't bother with the issue.
I think it's okay unless there's a problem in the application that I can't see right now...

Thank you again !

 

StringGrid Demo.zip

Link to comment
Share on other sites

3 minutes ago, picyka said:

Disabling this feature there, if I want to get the data from the line to do something on the server, how would I have to synchronize it?

Well, there will be some method, say SaveChanges, in which the changed data is sent to the server...

Link to comment
Share on other sites

6 horas atrás, Sherzod disse:

Ok, então tente esta abordagem:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSAddListener('viewready', 'function(){this.getSelectionModel().suspendEvent("select")}');
end;

 

And in this case here, let's say I want to click on an actionColumn to open a Form, how would I do it?
I would have to position the dataset on the server

Link to comment
Share on other sites

3 minutes ago, picyka said:

And in this case here, let's say I want to click on an actionColumn to open a Form, how would I do it?
I would have to position the dataset on the server

 

13 minutes ago, picyka said:

with the arrival of Grid Ligth

All these nuances are still worth considering.

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