Author Topic: Read Only Cells  (Read 7592 times)

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Read Only Cells
« on: September 19, 2014, 08:31:16 pm »
Hi,

i Have column groups(A ', B) - 1 column in Group A has a radio button - if it is yes then Group B should be grayed out (Users cannot edit or enter any data) , if it is NO then it should be editable.

Is there any group/column property to set the editable property or anything for the above mentioned requirement?

« Last Edit: October 10, 2014, 11:22:24 pm by paramquery »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Dependencies
« Reply #1 on: September 22, 2014, 01:51:09 am »
Every column has editable property, the callback variant can be used for the above requirement. The value of radio button can be checked in this callback as ui.rowData[ "dataIndx_of_radio_button_column" ] and return true/false accordingly.

http://paramquery.com/pro/api#option-column-editable

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Dependencies
« Reply #2 on: September 22, 2014, 07:54:23 pm »
Thank you , is there any css class to look Gray if editable is false ?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Dependencies
« Reply #3 on: September 22, 2014, 10:45:50 pm »
For that you have to take help of column.render callback for columns in group B.

In this callback check whether the cell is editable with isEditableCell API

http://paramquery.com/pro/api#method-isEditableCell

If non-editable then add class e.g., grayClass and if editable then remove the  class.

And then some css
Code: [Select]
div.pq-grid tr td.grayClass{
    color: gray;   
}
« Last Edit: September 22, 2014, 10:49:53 pm by paramquery »

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Dependencies
« Reply #4 on: September 23, 2014, 11:25:41 pm »
Hi,

I tried this(below code) in one of the columns in column B - but the class is applied only when the cell is clicked ... But i want all editable cells to be grayed out when i have fundvalue as "FI" ... Any suggestions ?

editable: function (ui) {
                 if (ui.rowData != undefined) {
                     var fundvalue = ui.rowData.funding;
                     if (fundvalue == "FI") {
                         //console.log(ui);
                         var ri = ui.rowIndx;
                        $grid.pqGrid("addClass", { rowIndx: ri, dataIndx: 'adminfeebasis', cls: 'grayClass' });
                         return false;
                     }
                     else {
                         return true;
                     }
                 }
                 else {
                     return true;
                 }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Dependencies
« Reply #5 on: September 23, 2014, 11:32:46 pm »
Every callback has its own separate purpose.

As mentioned in the previous reply, please add / remove class in the column.render callback. ( not in column.editable )

http://paramquery.com/pro/api#option-column-render

And check this demo for how to add class in the current cell using JSON format

http://paramquery.com/pro/demos/render_cells

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Dependencies
« Reply #6 on: September 26, 2014, 07:15:56 pm »
Hi,

I have written in render callback function - but still unless you are in the column B and click this class is not getting rendered - But i am looking for is if you change value in Column A - these cells need to be grayed out before you going into the cells

  render: function (ui) {
                 var rowix = ui.rowIndx,
                 dataIndx = ui.dataIndx;
                 if ($("#medicaltable").pqGrid("isEditableCell", { rowIndx: rowix, dataIndx: dataIndx })) {
                     $grid.pqGrid("removeClass", { rowIndx: rowix, dataIndx: 'adminfeebasis', cls: 'grayClass' });
                 }
                 else {
                     $grid.pqGrid("addClass", { rowIndx: rowix, dataIndx: 'adminfeebasis', cls: 'grayClass' });
                 }
             },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Dependencies
« Reply #7 on: September 29, 2014, 03:22:14 pm »
Take help of cellSave or change event to refresh the corresponding cell in column B in same row whenever value in Column A is changed.

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Dependencies
« Reply #8 on: October 01, 2014, 06:24:24 am »
I Used cellClick - so far it is working the way i want - Thank You so much

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Dependencies
« Reply #9 on: October 10, 2014, 11:21:31 pm »
I'm not sure how you created read only cell with cellClick event. Please check this demo which is relevant to your question

http://paramquery.com/pro/demos/readonly_cells
« Last Edit: October 10, 2014, 11:24:41 pm by paramquery »

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Read Only Cells
« Reply #10 on: October 12, 2014, 12:56:38 am »
This makes more sense :) - Thank you