Announcement

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

    SelectItem: Add Entry/record into a selectItem after it has been drawn

    Hi every one,

    I would like to know if it is possible programmatically to change (remove, add) the records of a SelectItem after this Selectitem has been drawn?

    Thanks for any help

    #2
    How are you populating the SelectItem with setValueMap() or an optional data source? The answer to your question is yes, but need to know more about what you are doing to help you achieve it.

    Comment


      #3
      Hi svjard,

      thanks for your answer. I'm populating the SelectItem with #setValueMap(). Can you please tell me what to do to achieve it?

      Thanks a lot...

      Comment


        #4
        @rlagoue: You can call setValueMap() repeatedly to change the values, however bad news is you sort of need to track the values yourself. Here is a code example:
        Code:
        public void onModuleLoad() {
        	DynamicForm form = new DynamicForm();
        	form.setNumCols(2);
        	final SelectItem  itemName = new SelectItem ("itemName");  
        	itemName.setTitle("Item Name");
        	final LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
        	valueMap.put("A", "A");
        	valueMap.put("B", "B");
        	valueMap.put("C", "C");
        	itemName.setValueMap(valueMap);
        	
        	ButtonItem b1 = new ButtonItem("b1", "Remove Last Value");
        	b1.addClickHandler(new ClickHandler() {
        		@Override
        		public void onClick(ClickEvent event) {
        			valueMap.remove("C");
        			itemName.setValueMap(valueMap);
        		}
        	});
        	ButtonItem b2 = new ButtonItem("b2", "Add New Value");
        	b2.addClickHandler(new ClickHandler() {
        		@Override
        		public void onClick(ClickEvent event) {
        			valueMap.put("D", "D");
        			itemName.setValueMap(valueMap);
        		}
        	});
        	form.setItems(itemName, b1, b2);  
        	     
        	form.draw();
        }
        @smuhanguzi : Well the message sums it up pretty well, did you include the correct name, driver, etc.. I would go back through the documentation one more time.

        Comment


          #5
          @svjard

          thanks for your sample code. I was worrying because you code didn't work as I tested it. However I remarked it was dued to my browser, the made the first test on chrome, and it didn't work there, after running the same thing in firefox, all worked perfectly.

          Thanks a lot.

          @Isomorphic.

          Are there known problems related to chrome?

          Comment


            #6
            I ran it in Chrome, it works perfectly. I hope your not on like a beta version of chrome or something? What is not working? Anything in the error console?

            Comment


              #7
              Hi svjard,

              on chrome the combobox simply doesn't show the entries... I noticed also that since smartgwt2.2 has been released, the showcase doesn't work on my chrome.

              Thanks a lot for your help.

              I will now try to reinstall my chrome.

              Comment


                #8
                Hi

                i just reinstalled my chrome browser. I also deleted all users data from my computer after uninstalling.

                So the showcase of Smartgwt are working, but the problem with SelectItem still persists.

                Now I'm really confused...

                Any help is welcome.

                Thanks

                Comment


                  #9
                  Post the precise version / build of Chrome you're using.

                  Comment


                    #10
                    What version of Chrome? Also your on the latest smartgwt - gwt versions? And are you deploying this to a server and then running, or in hosted mode? Post all relevant information, and do the selectitems in the showcase also show no entries?

                    Comment


                      #11
                      I would say the actual one. Here is the number I get from chrome "5.0.375.55"

                      Comment


                        #12
                        I'm on the same, so that is not the issue

                        Comment


                          #13
                          Hello,

                          what if the data where fetched to SelectItem using a datasource? In that case how could we override the returned resultset and add or remove records?

                          Thanks

                          Comment


                            #14
                            Same question

                            Originally posted by vagkavan View Post
                            Hello,

                            what if the data where fetched to SelectItem using a datasource? In that case how could we override the returned resultset and add or remove records?

                            Thanks
                            I have the same question

                            Comment


                              #15
                              Same problem here:

                              Simple SelectItem
                              without an optionDataSource:

                              calling setValueMap in a callback of a DataSource fetch,
                              will not set the values to the SelectItem.
                              Using newest version here.

                              Comment

                              Working...
                              X