Announcement

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

    ListGrid field editable, when record added, and non-editable, when record updated.

    Dear all,
    I am trying to achieve the following scenario and I don't seem to be able to do so using the known to me SmartGWT classes/functions. It might be an unsupported scenario, so please let me know it this is the case :D

    I have a ListGrid with multiple ListGridFields set up. All of them have a SelectItem defined as their EditorType items. Especially for the first column of the ListGrid I would like to achieve a special edit/add functionality. If the user adds a new row, the new row should enter editing mode and the first column should allow, through its Selectitem, the selection of one of the available values. If the user double clicks on an existing record, the record should enter into editing mode and the first column should be non-editable by the user. In essence, I want the first column of a record to be either editable - using the SelectItem - when it is freshly added to the ListGrid, or non-editable, when it is updated. I fail to achieve this by using setCanEdit for the field according to the action. Any better idea? Is this even possible?

    Thanks in advance for your suggestions!

    #2
    Initailly set
    setCanEdit(false);

    When editbutton clicked
    make setCanEdit(true);
    then startEditing(int rownum,int colnum,false);

    After u save ,reset to setcanedit(false);

    Also if u add new row,
    addbutton clicked,add new record,then
    make setCanEdit(true);
    then startEditing(int rownum,int colnum,false);

    I have tried this and it works fine

    Comment


      #3
      Thanks a lot for your reply.
      I tested you proposal and since I do not have an edit button, I put the related code in the EditorEnterHandler. For the case of editing/updating a record this works as expected. However, when I try to add a record, issues arise. I do get the SelectItem editor for the first field. When I select one value and move to select the next field's value I have two problems. Firstly the first field "freezes" to the selected value and it is not possible for me to go back and change its value to a new one. This can be solved with a delete and a subsequent add of a new record, but I wouldn't consider this very friendly. I would accept it though, if I didn't have the second problem. The code that provides the value of the first field as input for the select item of the second field, which works perfectly in the edit case, fails to trigger the fetch of new values of this second field's select item.

      Comment


        #4
        Hello

        In case of add new record

        if ur add event happened,u put all the fields setcanedit(true) and startediting() [note:- Since not only for the grid,but also listgridfield have the method of setcanedit(),for the problem of freezing,there is also method to setcanfreeze()]

        after add operation,setcanedit(false) in listgrid

        In case of edit,u put the firstfield setcanedit(false) and others true and startediting() the particular row,it will works

        Hop this may be ur requirement,check it out.........

        Comment

        Working...
        X