Jump to content

Tunidbgrid: how to force changes in current cell are saved ?


Roberto Nicchi

Recommended Posts

If some data is changed in the current cell, is there a way to force the grid to post the data ?

I have tryed to use the dataset (if dataset.state=dsedit then dataset post) but seems that the dataset state is not changed if the focus doesn't exit the cell.

This lead to an exception later in the app: "Grid is in dirty state. No more updates can be applied."

thanks 

Link to comment
Share on other sites

1 hour ago, Sherzod said:

Hello, 

Could you please clarify your case? 

I can try :)

I have a form with some unigui components. One is a TuniDbGrid (let's call it the Xgrid). The xgrid is connected to a mem table (a TdxMemData)

The form shows the data of a specific subject (let's say a customer)

F10 is defined to execute a procedure that save the data. F8 save data and move to the prior customer, F9 save data and move to the next customer.

In the Xgrid the user change a cell (could be a numeric value or a lookup field or whatever you want) and doesn't press tab or click in another component, the focus remain in the cell. If now press F10 or F8 or F9 how can i save in the dataset the data in the cell ?

thanks

 

 

Link to comment
Share on other sites

40 minutes ago, Roberto Nicchi said:

In the Xgrid the user change a cell (could be a numeric value or a lookup field or whatever you want) and doesn't press tab or click in another component, the focus remain in the cell. If now press F10 or F8 or F9 how can i save in the dataset the data in the cell ?

  if (dbGrid.DataSource.DataSet.State in [dsEdit]) then
    dbGrid.DataSource.DataSet.Post;

?

Link to comment
Share on other sites

1 hour ago, Sherzod said:

  if (dbGrid.DataSource.DataSet.State in [dsEdit]) then
    dbGrid.DataSource.DataSet.Post;

?

No, this doesn't work because the state in not dsEdit. The state wil be dsedit only if the user type the value and exit the cell (with tab for example or click in another component).

Link to comment
Share on other sites

3 minutes ago, Roberto Nicchi said:

No, this doesn't work because the state in not dsEdit. The state wil be dsedit only if the user type the value and exit the cell (with tab for example or click in another component).

I'm not sure...

Link to comment
Share on other sites

2 hours ago, Roberto Nicchi said:

Project1.zip 56.16 kB · 1 download

Can you try this approach?

UniDBGrid1 -> ClientEvents -> UniEvents ->

function cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
    if (e.keyCode === 121) {
        sender.editingPlugin.completeEdit();
    }
}

 

Link to comment
Share on other sites

18 hours ago, Sherzod said:

Can you try this approach?

UniDBGrid1 -> ClientEvents -> UniEvents ->


function cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
    if (e.keyCode === 121) {
        sender.editingPlugin.completeEdit();
    }
}

 

I have tryed this workaround and in the example work. Unfortunately in my application i have problems to make it work. The cause seems to be the "bug" i have reported in portal: FSD-4075 Onkeydown executed twice

Link to comment
Share on other sites

Regarding this thing i have rethinked my idea. I thing i'll leave the default behaviour. The user change the cell value and have to press enter or press tab to confirm the data. It's acceptable.

Anyway the autopost property, present for checkboxes, could be extended to others comumn types. If possible add this request to the future unigui development.

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