Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to make a particular editable in a list grid keeping other rows uneditable?

    Hello Sir

    I am using Smart Client V10.0 for my project. I have been stuck in a phase where I need to make all rows un editable except one which I select through the checkbox. I have pasted the code below. I will really appreciate if you can give me a helping hand in this.

    Code:

    departments: isc.ListGrid.create({
    ID: "departmentsID",
    width: 550,
    height: 150,
    canEdit: true,
    editEvent: "click",
    modalEditing: true,
    selectionType: "single",
    alternateRecordStyles: true,
    showEmptyMessage: false,
    selectionAppearance: "checkbox",
    fields: [
    {name: "description", type: "text", canEdit: false},
    {name: "view", type: "boolean", width: 70,
    changed: function(form, item, value) {
    if (value == false) {
    departmentsID.setEditValue(item.rowNum, 2, false);
    departmentsID.setEditValue(item.rowNum, 3, false);
    }
    }
    },
    {name: "copy", type: "boolean", width: 70,
    changed: function(form, item, value) {
    if (value == true)
    departmentsID.setEditValue(item.rowNum, 1, true);
    }
    },
    {name: "edit", type: "boolean", width: 70,
    changed: function(form, item, value) {
    if (value == true)
    departmentsID.setEditValue(item.rowNum, 1, true);
    }
    }
    ]
    }),
    /*

    Here, I want the particular row (which row is selected through checkbox(the one in bold in code) ) to be selected keeping other rows of list grid non editable. I will appreciate your help. Thanks!

    #2
    You can override canEditCell() and only return true for selected records - for example, you could check grid.isSelected(grid.getRecord(rowNum)).
    Last edited by Isomorphic; 27 Sep 2016, 04:54.

    Comment


      #3
      I re-wrote the code as suggested. But, I am getting an error "unable to get property rowNum" when I trying to multiple boxes in the selected row. Screenshot is attached to support.



      Code:
      departments: isc.ListGrid.create({
      ID: "departmentID",
      width: 550,
      height: 150,
      canEdit: false,
      editEvent: "click",
      modalEditing: true,
      selectionType: "single",
      alternateRecordStyles: true,
      showEmptyMessage: false,
      selectionAppearance: "checkbox",
      fields: [
      {name: "description", type: "text", canEdit: false},
      {name: "view", type: "boolean", width: 70,
      changed: function(form, item, value) {
      if (value == false) {
      wildware.EditUserWindow.departments.setEditValue(item.rowNum, 2, false);
      wildware.EditUserWindow.departments.setEditValue(item.rowNum, 3, false);
      }
      }
      },
      {name: "copy", type: "boolean", width: 70,
      changed: function(form, item, value) {
      if (value == true)
      wildware.EditUserWindow.departments.setEditValue(item.rowNum, 1, true);
      }
      },
      {name: "edit", type: "boolean", width: 70,
      changed: function(form, item, value) {
      if (value == true)
      wildware.EditUserWindow.departments.setEditValue(item.rowNum, 1, true);
      }
      }
      ],
      canEditCell: function(rowNum, colNum) {
      if (departmentID.isSelected(departmentID.getRecord(rowNum)) == true) {
      return true;
      }
      else
      return false;
      }
      })

      Comment


        #4
        You just need to set canEdit:true on your grid, instead of canEdit:false

        Comment


          #5
          It got solved! Thank you sir! But, is there a bug in Listgrid field type "boolean" while toggling.It always shows the above error when I am clicking the checkboxes of "view" or "copy" or "edit"

          code:

          departments: isc.ListGrid.create({
          ID: "departmentID",
          width: 550,
          height: 150,
          canEdit: true,
          editEvent: "click",
          modalEditing: true,
          selectionType: "single",
          alternateRecordStyles: true,
          showEmptyMessage: false,
          fields: [
          {name: "description", type: "text", canEdit: false},
          {name: "view", type: "boolean", width: 70,
          changed: function(form, item, value) {
          if (value == false) {
          wildware.EditUserWindow.departments.setEditValue(item.rowNum, 2, false);
          wildware.EditUserWindow.departments.setEditValue(item.rowNum, 3, false);
          }

          }
          },
          {name: "copy", type: "boolean", width: 70,
          changed: function(form, item, value) {
          if (value == true)
          wildware.EditUserWindow.departments.setEditValue(item.rowNum, 1, true);
          }
          },
          {name: "edit", type: "boolean", width: 70,
          changed: function(form, item, value) {
          if (value == true)
          wildware.EditUserWindow.departments.setEditValue(item.rowNum, 1, true);
          }
          }
          ]
          })

          Thank you again!

          Comment


            #6
            item.rowNum isn't valid - try item.getGridRowNum()

            Comment

            Working...
            X