Jump to content

How to disable key press on UniDBGrid


carrera

Recommended Posts

Hi,

Let's say i have 3 columns in UniDBGrid

 

Row No | ColA | ColB

 1             111      +

 2             222     +

 3             333     -

........

 

if cursor point on row that ColA Value = '222', i need to disable UniDBGrid key press

I Think ExtJS Event can handle this, but not sure how do i call js function

function keypress(e, t, eOpts)
{
    var me = MainForm.UniDBGrid1;
    // not sure how to get dbgrid value in JS
    // ex. if  Dataset.fieldByName('ColA').AsString = '222' then 
    //        Key := #0
}

Thank you

Link to comment
Share on other sites

Hi,

 

Can you try this approach for now ?!:

 

UniDBGrid -> ClientEvents -> ExtEvents -> beforeedit fn:

function beforeedit(editor, context, eOpts)
{
    var me=context;
    if (me.column.dataIndex == "1" && me.originalValue == "222") {
        return false;
    }
}

Best regards.

Link to comment
Share on other sites

 :)

   If i want to get value from Another Column, how can i re-write this code

Assume user click (Focus) in column B and i need to get value from Column A

 if (me.column.dataIndex == "2" && ColAValue = "222") {
  return false;
    }

Thanks  :)

Link to comment
Share on other sites

Ok, then you can use this:

function beforeedit(editor, context, eOpts)
{
    var me=context;
    
    //me.record.data[yourColIndx]

    if (me.record.data[1] == "222") {
        return false
    }
}
Link to comment
Share on other sites

 

Ok, then you can use this:

function beforeedit(editor, context, eOpts)
{
    var me=context;
    
    //me.record.data[yourColIndx]

    if (me.record.data[1] == "222") {
        return false
    }
}

Work as expected!

Thank you

Link to comment
Share on other sites

  • 2 years later...
On 3/30/2017 at 1:46 AM, Sherzod said:

Ok, then you can use this:


function beforeedit(editor, context, eOpts)
{
    var me=context;
    
    //me.record.data[yourColIndx]

    if (me.record.data[1] == "222") {
        return false
    }
}

Hi Sherzod,

If grid column is allow to move the index maybe wrong, how to get the colindex by field name.

Can you assist me in this.

Thanks in advance

 

Link to comment
Share on other sites

4 hours ago, Sherzod said:

Hi,

Maybe you need to use like this:


me.record.data[context.colIdx]

 

This still cannot work.

I am using Unigui demo Column Sort to test.

 

Example For row City = "Christiansted",  for row City = "Christiansted" and Company Column field not allow to edit.

function beforeedit(editor, context, eOpts)
{
    var me=context;

    if ((me.column.dataIndex == "1") && (me.record.data[4] == "Christiansted")) {
        return false;
    }
    
}                             

Above code is ok if Column City & Company not allow to move.

 

If allow to move still wrong.

 

Please advice Thanks

 

Link to comment
Share on other sites

28 minutes ago, Sherzod said:

If not difficult can you make a simple testcase for reproduce? 

This testcase is ok if you no move the column

Requirment is Row Customer No 1384 & 1356 city is Christiansted, so Company Column for this 2 row is not allow to edit. other is allow to edit.

 

Testing steps

Step 1 You try to move the Company Column after Addr1

Issue : Company Column become allow to edit and Addr1 not allow to edit  ====> because me.column.dataIndex == "1"

Step 2 : You try to move the City Column after State

Issue : All column allow to edit  ====> because me.record.data[4] == "Christiansted"

Please advice.

Thanks

 

Cell Disable.7z

Link to comment
Share on other sites

On 7/10/2019 at 11:21 AM, Masteritec said:

This testcase is ok if you no move the column

Requirment is Row Customer No 1384 & 1356 city is Christiansted, so Company Column for this 2 row is not allow to edit. other is allow to edit.

 

Testing steps

Step 1 You try to move the Company Column after Addr1

Issue : Company Column become allow to edit and Addr1 not allow to edit  ====> because me.column.dataIndex == "1"

Step 2 : You try to move the City Column after State

Issue : All column allow to edit  ====> because me.record.data[4] == "Christiansted"

Please advice.

Thanks

 

Cell Disable.7z

Any update on this?

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