Author Topic: Non-editable Cells - Required ? - Need this -IMportant  (Read 3377 times)

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Non-editable Cells - Required ? - Need this -IMportant
« on: October 15, 2014, 06:49:31 pm »
Hi,

Resolved all other issues i was having before - only 1 requirement -

If i change funding value to SI - admin fees columns become editable - I am trying to write a validation call back to make basic admin fee and total admin fee as required when the cell is editable ... I am not able to accomplish this ... Can you help me with an example on how to do this please?


Also, if you can tell me if there is any way to add tootltip like we add class

Ex:  $grid.pqGrid("addClass", { rowIndx: rowIndx, dataIndx: dataIndx, cls: 'yellow' });

Thanks much !
« Last Edit: October 16, 2014, 06:55:52 pm by rgorantla »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Non-editable Cells - Required ? - Need this -IMportant
« Reply #1 on: October 16, 2014, 07:58:24 pm »
Code: [Select]
if (grid.isEditableCell({ rowIndx: rowIndx, dataIndx: ui.column.dataIndx }) == true) {
   if(ui.value == null || ui.value == "" ){
        return false;
   }
   else{
        return true;
   }
}
else{
  return true;
}
« Last Edit: October 16, 2014, 08:02:00 pm by paramquery »

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Non-editable Cells - Required ? - Need this -IMportant
« Reply #2 on: October 16, 2014, 11:37:14 pm »
Hi,

i wrote the same thing - but the issues is - when you click save though this cell is non-editable - focus will be on this cell until you enter soemthing

validations:[ { type:function(ui)
             {
                 var grid = $(this).pqGrid('getInstance').grid;
                 if (grid.isEditableCell({ rowIndx: rowIndx, dataIndx: ui.column.dataIndx }) == true)
                 {
                     if (ui.value == null || ui.value == "")
                     {
                         ui.icon == 'ui-icon-info';
                         ui.msg = "Required";
                         return false;
                     }
                     else
                     {
                         return true;
                     }
                 }
                 else
                 {
                     return true;
                 }
             }
             }],

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Non-editable Cells - Required ? - Need this -IMportant
« Reply #3 on: October 17, 2014, 12:25:32 am »
you are right. This is an undesirable issue which would be fixed in next release.

And I found the reason for this happening is when field value is null grid considers it invalid data.

the workaround is to put "" in that field. "" can be put into that field by addRow and updateRow ( along with checkEditable: false )

updateRow({rowIndx: rowIndx, row: { adminfees: ""}, checkEditable: false })

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Non-editable Cells - Required ? - Need this -IMportant
« Reply #4 on: October 22, 2014, 11:08:14 pm »
As a side note, you might need to reduce the repetition of code.

I see you have created separate validation and editor function for every column even when the logic is same in every function. You could write a common named function and use it for different columns.