Announcement

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

    DynamicForm and ListGrid Client side won't take value from DateTimeItem

    Be sure your post includes:

    SmartGWT 2.2-2.3 nightly downloaded 08262010
    Firefox 3.6.12 in Development Mode

    I have a DynamicForm that holds 4 Item objects 1 TextItem, 2 DateTimeItem's and a ButtonItem.
    The user will enter a random alphanumeric text in the first and select a date/time from the start and end datetime fields then click on "Create Keycode" this should then take those values and create a ListGridRecord and add it to our ListGrid.

    If I use a DataSource client side only no data is added to the ListGrid, no errors, nothing.
    If I use ListGridFields and only enter the keycode the Keycode is added as a new record to the ListGrid, if I enter either DateTimeItem then the record doesn't show.

    Code:
    //Form
    final DynamicForm formKeycodeModal = new DynamicForm();
    final TextItem txtKeycodeVal = new TextItem("keycodeVal", "Enter Keycode Value");
    final DateTimeItem startKeycodeDate = new DateTimeItem("startKeycodeDate", "Keycode Start");
    final DateTimeItem endKeycodeDate = new DateTimeItem("endKeycodeDate", "Keycode End");
    final ButtonItem biCreateKeycode = new ButtonItem("btnCreateKeycode", "Create Keycode");
    formKeycodeModal.setFields(txtKeycodeVal, startKeycodeDate, endKeycodeDate, biCreateKeycode);
    
    //ListGrid to put the values into 
    final ListGrid keycodesLGW = new ListGrid();  
    keycodesLGW.setWidth("100%");  
    keycodesLGW.setHeight("38%");  
    keycodesLGW.setLeft(350);  
    keycodesLGW.setShowAllRecords(true);  
    keycodesLGW.setEmptyMessage("Rows Added Here");  
    
    //I've also tried just using ListGridField's and the Keycode gets placed into our ListGrid but if I enter DateTimes it doesn't
    DataSource ds = new DataSource();
    ds.setFields(
    		new DataSourceTextField("keycode", "Keycode"),
    		new DataSourceDateTimeField("startdt", "Start Date"),
    		new DataSourceDateTimeField("enddt", "End Date")
    	);
    ds.setClientOnly(true);
    
    keycodesLGW.setDataSource(ds);
    
    
    //Once Create button is clicked capture our values and create our ListGridRecord then add it to our ListGrid
    biCreateKeycode.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				//Get existing records and add a new one then set it back on our table
    				
    				ListGridRecord tmp = new ListGridRecord();
    				Object code = txtKeycodeVal.getValue();
    				if(code != null) {
    					tmp.setAttribute("keycode", code);
    					Object start = startKeycodeDate.getValue();
    					if(start != null) {
    						tmp.setAttribute("startdt", start);
    					}
    					Object end = endKeycodeDate.getValue();
    					if(end != null) {
    						tmp.setAttribute("enddt", end);
    					}
    					keycodesLGW.addData(tmp);
    				}
    				else {
    					SC.say("You must enter a keycode value");
    				}
    				
    			}
    		});

    #2
    See the FAQ on grids not updating - you have no primary key.

    Comment


      #3
      Originally posted by Isomorphic
      See the FAQ on grids not updating - you have no primary key.
      I added a primary key and I get the same issue, no change.

      Should I be using ListGridField or a DataSource for this, it is client side only. After they enter all the entries they want I'll pull the data form the ListGrid and put it into my own custom object in order to send it to the server.

      Should the ListGridRecord be setup a certain way?

      Code:
      DataSource ds = new DataSource();
      DataSourceTextField keyTxtFld = new DataSourceTextField("keycode", "Keycode");
      keyTxtFld.setPrimaryKey(true);
      
      DataSourceDateTimeField startDTFld = new DataSourceDateTimeField("startdt", "Start Date");
      DataSourceDateTimeField endDTFld = new DataSourceDateTimeField("enddt", "End Date");
      
      ds.setFields(keyTxtFld, startDTFld, endDTFld);
      
      ds.setClientOnly(true);

      Comment


        #4
        See the rest of the FAQ on grids not updating :)

        There are several steps, and diagnostics you should post if you can't solve it.

        Comment


          #5
          Originally posted by Isomorphic
          See the rest of the FAQ on grids not updating :)

          There are several steps, and diagnostics you should post if you can't solve it.
          I'm guessing this is the FAQ you want me to review : http://forums.smartclient.com/showthread.php?t=8159#aGrid

          I've checked the names they're fine, I've tried the debug level on ResultSet I get nothing, I've looked at the RPC it say's client only and add successful but nothing shows in the ListGrid.

          Not sure what else to check.

          Comment


            #6
            Is fetchData() ever called on the ListGrid? If not, it is not connected to the DataSource and has no ResultSet, so no cache sync will occur.

            Comment


              #7
              Originally posted by Isomorphic
              Is fetchData() ever called on the ListGrid? If not, it is not connected to the DataSource and has no ResultSet, so no cache sync will occur.
              It was not set, I've changed that and now if i enter a Keycode without datetimes it works...if I enter a datetime it doesn't.

              I see this in the Developer Console now, doesn't seem to help much in this matter.
              16:02:03.584:TMR1:DEBUG:ResultSet:isc_ResultSet_1 (created by: isc_ListGrid_1):dataSource data changed firing
              16:02:03.585:TMR1:INFO:ResultSet:isc_ResultSet_1 (created by: isc_ListGrid_1):updating cache in place after operationType: add, allMatchingRowsCached true


              I've also uploaded a very short video, to show what it's doing in case I'm not explaining it correctly.

              http://screencast.com/t/QruOTNGV4q

              Thank you,

              Comment


                #8
                If the keyCode is the PK, and you're doing another add, then you've got a PK collision.

                Comment


                  #9
                  Originally posted by Isomorphic
                  If the keyCode is the PK, and you're doing another add, then you've got a PK collision.
                  How can I have a pk collision if the keycode I enter is different each time?

                  The first time I entered 1234 and the second entry was 12345.

                  Without datetime's it worked with a pk of 1234 and with it, it doesn't using a pk of 12345.

                  Comment


                    #10
                    Right, sorry, missed the addition of an extra "5" in the video.

                    Each individual part of the code you've posted now appears correct. The problem is somewhere in the code you're not showing or how you've combined the code. Can you post a standalone test case?

                    Comment


                      #11
                      Originally posted by Isomorphic
                      Right, sorry, missed the addition of an extra "5" in the video.

                      Each individual part of the code you've posted now appears correct. The problem is somewhere in the code you're not showing or how you've combined the code. Can you post a standalone test case?
                      Created a ticket in order to upload the testcase.

                      http://code.google.com/p/smartgwt/issues/detail?id=530

                      Comment


                        #12
                        Sorry, what we mean by a testcase is a single file (or minimum set of files) that can be dropped into the standard SDK and run. We need to see something that clearly suggests a bug or allows us to immediately identify the usage error, as opposed to having to troubleshoot some kind of misconfiguration in your project or other problem.

                        Comment


                          #13
                          Originally posted by Isomorphic
                          Sorry, what we mean by a testcase is a single file (or minimum set of files) that can be dropped into the standard SDK and run. We need to see something that clearly suggests a bug or allows us to immediately identify the usage error, as opposed to having to troubleshoot some kind of misconfiguration in your project or other problem.
                          Attached file that has the issue in it, I use a button on click to open this it's a Modal Window basically.

                          File attached : PromoAddKeycodes.java
                          Attached Files

                          Comment


                            #14
                            At this point this looks just like many (working) samples.

                            Do you get different results if you call addData() directly on the DataSource (keycodesLGW.getDataSource().addData()) instead on the ListGrid?

                            Comment


                              #15
                              Originally posted by Isomorphic
                              At this point this looks just like many (working) samples.

                              Do you get different results if you call addData() directly on the DataSource (keycodesLGW.getDataSource().addData()) instead on the ListGrid?
                              I get the same issue.
                              If I add just text in the first box and click on my button it adds if I try to use the calendar to add a datetime in the other two as well it fails.

                              Are you using a newer version of the 2.2 nightly release or ?

                              Is it safe to upgrade to the latest, mine is from August as in my first post... maybe I need to upgrade it.
                              Last edited by gilcollins; 29 Oct 2010, 14:52.

                              Comment

                              Working...
                              X