Frage

Hi I'm new bee to dojo and stuck into a simple problem. I'm getting an error Tried to register widget with id==listGrid but that id is already registered. Let me share a piiece of my code with you

I have Three radio button and onclick on any of the radio button will result in grid. I'm using same div for all three radio button. First time the grid will come for first radio button but second time I get an above error. I'm calling this function on click of radio button

_showList:function()
{
    var item = this.gc.getSelectedItem()
    var id=item.id;
    var cont = 'zone';
    var action='getCityListById';
    var controller='network';
    this.cityGc = new GridViewControl({columns:
        [
          {action:action, controllerName:controller,parameters: {id:item.id, cont: cont}},
          {name:"City Name", field:"name", width: "200px", editable: false}
          ], diff:220
    },this.zoneListGrid);           
}

zoneListGrid is a dojo attach point which is same for all three radio buttons. please suggest something through which I can work out. Thanks in advance

War es hilfreich?

Lösung

Since every click on a radio button will trigger this piece of code, dojo will try to create another grid component on the second click. Because there is already a widget present on that attach point, the error is thrown.

Either you re-use the grid that is already present (do a === null check on this.cityGc) or you destroy the existing grid first (this.cityGc.destroy()).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top