Jump to content

Recommended Posts

Posted
function cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
   if (e.getKey() == 40) 
    {
       if (rowIndex==Last Row) <---- problem
       {
           e.stopEvent ();                            
           ajaxRequest(sender, 'AppendRow', [] );
       } 
    }
}

this is my code.

tnx

Posted

hi .

it is usefull post.thanks

I use vk_down and Tab

I'm use tab key to fill columns data.

I want to append a new record when tab key reach Last Column of last row

and user press Tab again to append new record

 

Best regards.

Posted

Hi,

 

You can try like this:

 

1.

type
  TUniExDBGrid = class(TUniDBGrid)
end;

2.

procedure TMainForm.UniDBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  isLastRecord: Boolean;
begin
  isLastRecord := (Sender as TUniDBGrid).DataSource.DataSet.RecNo = (Sender as TUniDBGrid).DataSource.DataSet.RecordCount;
  
  if (Key = VK_TAB)and(isLastRecord)and(TUniExDBGrid(Sender).CurrCol=(Sender as TUniDBGrid).Columns.Count-1) then
  begin
    // your logic
    (Sender as TUniDBGrid).DataSource.DataSet.Append;
  end;
end;

Best regards.

  • 4 years later...
Posted

Ver: 1.90.0.1547 Trial

I follow the Sherzod method

Error Message:  TuniCustomDBgrid.SetCellValue: RecNo Mismatch![4: -1].

Please help, thank you

 

 

Posted
5 hours ago, kentiger said:

Ver: 1.90.0.1547 Trial

I follow the Sherzod method

Error Message:  TuniCustomDBgrid.SetCellValue: RecNo Mismatch![4: -1].

Please help, thank you

 

 

Hello

Can you please create a test case?

Posted
6 minutes ago, eduardosuruagy said:

This error is old and they have never been able to correct it.

Hello

This error happens when you make changes when grid is dirty. There is no way to fix this error as you need to change your code. This error is a precaution.

Posted
1 hour ago, Hayri ASLAN said:

Hello

This error happens when you make changes when grid is dirty. There is no way to fix this error as you need to change your code. This error is a precaution.

Sorry, I didn't understand the translation of what would be "grid is dirty"

Posted
14 minutes ago, eduardosuruagy said:

Sorry, I didn't understand the translation of what would be "grid is dirty"

Hello

If grid needs to refresh itself, that means grid is dirty.

Let say you have 3 records and in server side you refreshed the query and you have 4 records now.

In the client side grid needs to refresh. Before it refresh if you try to access 4th record in client side, you will get error.

Posted
2 hours ago, Hayri ASLAN said:

Olá

Se a grade precisa se atualizar, isso significa que a grade está suja.

Digamos que você tenha 3 registros e no lado do servidor você atualizou a consulta e agora tem 4 registros.

Na grade do lado do cliente precisa ser atualizada. Antes de atualizar, se você tentar acessar o 4º registro no lado do cliente, obterá um erro.

can you show me an example?

 

I do a lot this way, I don't know if it's correct.

DataSet.Edit;
DataSet.FieldByName ('FIELD'). AsString: = 'Value';
DataSet.Post;
DataSet.ApplyUpdate (0);
DataSet.RefreshRecord;
dbgrid.RefreshCurrentRow ();

Posted

Hi, Hayri ASLAN

UniDbgrid1 have 3 Column

      badno    badname    description

My needs:

When in the add mode, after the user enters the data in the Description, press the down button, the system automatically Append new record

The following is my program

procedure TMainForm.UniDBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  isLastRecord: Boolean;
begin
  isLastRecord := Abs((Sender as TUniDBGrid).DataSource.DataSet.RecNo) = (Sender as TUniDBGrid).DataSource.DataSet.RecordCount;
  if (Key = VK_DOWN) and (isLastRecord) and(TUniDBGrid(Sender).CurrCol=(Sender as TUniDBGrid).Columns.Count-1) then
  begin
    (Sender as TUniDBGrid).DataSource.DataSet.Append;
  end;
end;

 

An error message will occur as follows-->TuniCustomDBgrid.SetCellValue: RecNo Mismatch![4: -1].

 

Please help, thank you

 

 

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