Announcement

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

    Can ListGrid selectionAppearance checkbox be hidden for some records?

    Hi,

    please give me some hints on if it's possble to hide or disable the selection checkbox for some records in ListGrid an leave it avaiable for others. I would like to make some records to be protected from be selected and then deleted by "delete selected" functionality in my app.

    Thank you,
    Andrew

    #2
    set the listgrid.canSelectProperty on the individual records you don't to be able to select

    Comment


      #3
      I tried to find "canSelectProperty" (or "canSelect") in smartgwr-2.2 java for ListGrid doc but was able to find only "setCanSelectAll()" that "Controls whether a checkbox for selecting all records appears in the header"
      I also tried ListGridRecord class for this property but in vain. Could you be, please, more presize and point me to the class and method?

      Thank you.

      Comment


        #4
        ListGridRecord.setAttribute("canSelect", false);

        Comment


          #5
          Thank you. It works fine.

          I did like that
          Code:
          listGrid.addDataArrivedHandler(new DataArrivedHandler() {
          	public void onDataArrived(DataArrivedEvent event) {
          		
          		ListGridRecord[] records =  MetaGrid.this.getRecords();
          		if (records != null && records.length > 0){
          			for (int i = 0; i < records.length; i++) {
          				boolean canBeSelected = isRecordCanBeSelected(records[i]);
          				records[i].setAttribute("canSelect", canBeSelected);
          			}
          		}
          	}
          });
          where isRecordCanBeSelected(...) incapsulates my custom logic.

          Is it optimial and there is no way to incorporate custom logic inside ListGrid by overriding some method to perform this logic during the grid drawing?

          Thank you.

          Comment


            #6
            Not sure what logic you are performing, that attribute could already be part of the records coming from the server. Why would you want to do this during drawing? Outside of having the information already there from the server, this is about as optimal as it gets.

            Comment


              #7
              Thanks again. Your point of having it ("canSelect":false) coming from server meets my need exactly.

              Thank you very much!

              Comment


                #8
                Hi again,

                Could you please tell me if there is a way to do the same with the "remove" field in ListGrid?

                I see the setCanRemoveRecords() methos in ListGrid and setIsRemoveField() method in ListGridFiled, but do not see any property to manipulate the "remove" column value on a row basis like it can be done with "canSelect" in ListGridRecord.

                Is it possible to hide a "remove" button/image for some rows and leave it avaiable for others?

                Thank you.

                Comment


                  #9
                  I don't think there is a flag for that. Best bet is it is really easy to create your own field to remove records and that field can easy check some attribute (e.g. "canRemove") for each record before it actually performs the remove operation.

                  Comment


                    #10
                    I have a listgrid which I declared/initialized in this manner:

                    ListGrid myListGrid = new ListGrid();

                    public MyConstructor(){

                    myListGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
                    myListGrid.setCanSelectAll(false);

                    }

                    The codes should disable the "check all" header, the problem is, each time an empty record is fetched, the checkbox appears on the header. Is this a bug or is there any way to circumvent this behaviour ?
                    Attached Files
                    Last edited by ea_potenciano; 21 Oct 2010, 18:53.

                    Comment

                    Working...
                    X