Announcement

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

    Retreiving information while Inserting data

    Hi,
    I'm using a DMI to insert data into database from a form. I call upon a add operation. I have a value in the database which needs to be returned when i call the add the function. I have set the a value to the DSResponse object, How do i get that object in the Client side when i call form.saveData()?
    Kindly advice.

    Thanks in advance.
    Last edited by ev.kaushik; 19 Mar 2008, 00:10. Reason: wrong subject

    #2
    If you want to send back an additional property in the added record, just pass it as part of dsResponse.setData() in your server code. If it's a field not declared in the DataSource, be sure dropExtraFields is set false or it will be dropped.

    If you instead want to send back separate objects, the best way is probably to use a queue of operations - see RPCManager.startQueue().

    Comment


      #3
      Could you please let me know where i can set the "dropExtraFields" property ?
      I'm not able to find out. Sample code will really be helpful.

      Thanks in advance...

      Comment


        #4
        Search the SmartClient Reference - it can be set in multiple places depending on what you want.

        Any time you see a mention of a method or property you don't understand, use the search feature in the SmartClient Reference to find documentation and examples.

        Comment


          #5
          Now i have set the property, but now i'm not able to access the value. How will i be able to get the data in my JS code. Will it be available as a return value when i call form.saveData()? Please let me know on how to get the data back from the server object.

          Thanks in advance...

          Comment


            #6
            If you have called dsResponse.setData(), on the client the data will be available as part of dsResponse.data. The dsResponse is one of the parameters to the callback of saveData(), and is also available in dataSource.transformResponse and other places.

            Comment


              #7
              I tried the following but the alert message dint get displayed.
              Could you point out the mistake.

              "roleId" is the name of the integer i'm setting on the server side dsResponse.setData(roleId);


              Code:
              click:function(){
              		      			CreateRoleForm.getItem('createdOn').setValue(new Date());
              		      			CreateRoleForm.getItem('createdBy').setValue(User);
              		      			CreateRoleForm.validate();
              		      			CreateRoleForm.saveData();
              		      			var roleId = dsResponse.data.getValue("roleId");
              		      			CreateRoleForm.reset();
              		      			alert(roleId);
                    			}
              Thanks in advance...

              Comment


                #8
                saveData() is asynchronous. You pass a callback to saveData() and that callback will be invoked when saveData() completes. See the docs for DataSource.fetchData() for examples of using callbacks - DataSource.fetchData() supports callbacks in the same way that DynamicForm.saveData() does.

                Comment


                  #9
                  i tried with following code as given in the docs. But the alert message gives the value as undefined.

                  what could be the possible error?
                  Code:
                  isc.IButton.create({
                  				//autoDraw : false,
                  				visibility:"hidden",
                  				ID: "saveRoleForm",
                        			title: "Save",
                        			click:function(){
                  		      			CreateRoleForm.getItem('createdOn').setValue(new Date());
                  		      			CreateRoleForm.getItem('createdBy').setValue(User);
                  		      			CreateRoleForm.validate();
                  		      			CreateRoleForm.saveData(null,"CreateRoleForm.getItem('roleId').setValue(data)");
                  		      			var roleId = CreateRoleForm.getValue('roleId');
                  		      			CreateRoleForm.reset();
                  		      			alert(roleId);
                        			}
                  	})

                  Thanks in advance...

                  Comment


                    #10
                    All of your code after the saveData() call is running immediately, before the save has even been submitted to the server. Again, saveData() is asynchronous. Any code that relies on the server's response to saveData() should be triggered from the callback.

                    Comment


                      #11
                      Thank you!!!!!
                      Its working!!!!!!!!!!!!!!!

                      Comment

                      Working...
                      X