Announcement

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

    SelectOtherItem not working if attached to a datasource

    I have a SelectOtherItem on my page and I need to fill it with values coming from the server. Cant hard code like in the smartgwt examples..

    If I dont attach it to the dataSource it doesnt show any value except for the "Other" option.. and if I do then the dataSource values appear but the Other option is lost..

    No errors at all in the Developer console either..

    Dont know what to do.. Any API's u think that can takes care of this??

    This is how I define the SelectOtherItem:

    Code:
    final SelectOtherItem tagItem = new SelectOtherItem("tags");
    		tagItem.setAutoFetchData(true);
    		tagItem.setTitle("Tag");
    		tagItem.setSelectOtherPrompt("Enter a new tag name");
    		tagItem.setOtherTitle("New Tag");
    		tagItem.setAllowEmptyValue(true);
    		tagItem.setOptionDataSource(tagsDS);
    		//tagItem.setEditorType(new SelectOtherItem());.. doesnt seem to have an effect
    Thanks,
    Hetal
    Last edited by hgaglani; 7 May 2009, 07:58.

    #2
    Any ideas for the previous problem.. ???

    I have a feeling its a bug coz from what I understand from the documentation of setOptionDataSource it will place a valueMap in the selectItem with the values of the records from the DataSource. So I guess the original value map of other field.. Do correct me if I m wrong..

    I need this functionality.. any help is greatly appreciated...

    Also, if a selectItem (connected to a Datasource) shows a set of values, how can I get the whole set of data in the selectItem.. getValue() just returns the selected value of the selectItem widget. I was looking for some API with the functionality similar to getRecords() of ListGrid which returns all the records of the grid.

    Really appreciate all the help..

    Thanks,
    Hetal

    Comment


      #3
      Any ideas guys.. is it not supported?? I tried if I could override some method.. but fail to understand what takes care of it...

      Also, I have checked all the possible API's on SelectItem but there isnt one that will return all the values in that drop down. Kindly share some ideas.. Cud an API like getAllData() be added??

      I have a listGrid wid some records... and I have a selectItem with a list of values(again coming from a datasource) which would be used to assign tags to the records in the grid. Something like the gmail labelling feature... infact something exactly like that..

      So now what I need is if I select some records in the grid wid tag "Test", then the SelectItem which has a list of tags.. should have a checked beside value "Test".. I see that the menuItem has the API setChecked().. but there is nothing like that on the SelectItem..

      Again, if support can be provided for this.. i would really really appreciate it..

      Thanks..
      Hetal

      Comment


        #4
        Fetch the data directly using DataSource.fetchData() and provide it to the SelectItem via setValueMap().

        Comment


          #5
          Tagging feature

          Thank you Isomorphic.. The solution u mentioned works.

          For my other questions since the SelectItem does not have a checked() API .. I changed the widget to use a MenuItem instead and its works fine in my standalone piece..

          Will post the code soon for everyone incase anybody is interested..

          Thanks,
          Hetal

          Comment


            #6
            Great, posting your solution so that others can benefit is always appreciated!

            Comment


              #7
              Applying Tags to grid records

              PFA the code for applying tags to grid records.

              It wouldnt be the most optimal code but have tried my best. Code has some comments explaining what the necessary structure does.

              As far as DS are concerned.. for the grid. there is a different DS... but I dont think its much needed for the tags since the widget is different and has a different DS. If its not very clear do let me know how else I can edit it so that its more useful to everyone.

              Any suggestions on improving the code are welcome..

              Hope its useful to all..!!
              Attached Files

              Comment


                #8
                Just one small question.. in the code I posted.. to get a new value for a new tag I have called.. SC.askForValue().. which gives a prompt with a blank field for the user to enter the value... but its way too big in width (approx 80% of the page whereas all the other prompts only take about 40%.. )

                I checked Dialog.js that is generated and I can see that for askForValue() the prompt's width is set to 80% of the page and I cudnt find an API on the SC like setProperty to set the width of the prompt... do u have any suggestions on how I can get a smaller prompt..???

                Thanks,
                Hetal
                Last edited by hgaglani; 4 May 2009, 10:39.

                Comment


                  #9
                  Can u suggest how I can change the Dialog.js file to change the default 80% to 40% coz.. I cant understand how I can change that in the jar or override it??

                  Pls suggest.. I really need to change that file..

                  Thanks,
                  Hetal

                  Comment


                    #10
                    Hi Hetal,
                    I've update SC.askForValue to use a more reasonable default width (275px). I've also added a method which allows you to explicitly pass in the Dialog properties. You can set the width or height of the Dialog properties to any value desired.


                    Code:
                        /**
                         * Show a modal dialog with a text entry box, asking the user to enter a value.
                         * <p>
                         * As with other convenience methods that show Dialogs, such as {@link #warn(String, String, BooleanCallback)} , the dialog is shown
                         * and the function immediately returns.  When the user responds, the provided callback is called.
                         * <p>
                         * If the user clicks OK, the value typed in is passed to the callback (including the empty string ("") if nothing was entered.  If the
                         * user clicks cancel, the value passed to the callback is null.
                         *
                         *
                         * <p>Keyboard focus is automatically placed in the text entry field, and hitting the enter key is the equivalent of pressing OK.
                         *
                         * @param title the title of the dialog
                         * @param message message to display
                         * @param defaultValue the default value of the text field
                         * @param callback Callback to fire when the user clicks a button to dismiss the dialog. This has the single parameter 'value',
                         * indicating the user entry, or null if cancel was pressed or the window closed
                         * @param dialogProperties additional properties of the Dialog
                         */
                        public static void askforValue(String title, String message, String defaultValue, ValueCallback callback, Dialog dialogProperties)
                    Sample code

                    Code:
                    Dialog dialogProperties = new Dialog();
                    dialogProperties.setWidth(300);
                    dialogProperties.setHeight(175);
                    SC.askforValue("Enter Value", "Please enter a value", "", new ValueCallback() {
                        public void execute(String value) {
                            ...
                        }
                    }, dialogProperties);
                    Sanjiv

                    Comment


                      #11
                      Hi Isomorphic. I know it's been a few years since this thread went silent, but do you intend to find or do you have a solution to this problem? I have a datasource attached to SelectOtherItem and I'd love to have the 'Other' option without decoupling it from it's RestDataSource. Your solution requires the intermediate step of fetching the data then creating a ValueMap. I guess I'd have to do the add operation myself aswell. Do you have a neater solution?

                      Comment


                        #12
                        Just wanted to also add my bump into this thread re SelectOtherItem.

                        Its the first FormItem I've used (admittedly not that many out of the full range) that doesn't to behave as nicely as the others with the DataSource concept.

                        Comment


                          #13
                          Example

                          Originally posted by Isomorphic View Post
                          Fetch the data directly using DataSource.fetchData() and provide it to the SelectItem via setValueMap().
                          I am having the same problem... Could you give me a detailed example?!?

                          Comment

                          Working...
                          X