Posted in: SPARK UI Toolkit Controls
Prashant TiwariDecember 5, 2016 at 9:40 am #3230
I started to implement Spark Service data table and this might be a very basic question.
But I cannot figure out how to bind variable to data returned by Ajax service.
I want to store the data returned through Ajax Service (attached to Service Data Table) and items selected through the table should get populated in the list selected variable of the bound variable.
However, that does not happen.When I try to debug, my bound variable does not have anything even though table shows data.SPARK SupportDecember 5, 2016 at 1:43 pm #3239
If you have the Service Data Table configured to display a Name Value Pair from the results for instance, you can bind the outer table to a NVP variable. Then call getData() on the table and the values will be returned.
If you want to return only the selected values, call getSelectedRecords().
See the following article for the available methods: http://support.salientprocess.com/docs/enterprise/ServiceDataTable.html
Stephen P.Prashant TiwariDecember 5, 2016 at 1:49 pm #3241
Thanks for your response Stephen.
I just tried that on DataLoad event and it still does not bind the values to the bound variable on the table.
Please advise what I am doing wrong.
If you can point me towards an example, that will be amazing.
This is what I have – on Service Data Loaded – “me.getData()” and this still does not set the bound variable.SPARK SupportDecember 5, 2016 at 3:57 pm #3245
If you have your Data service returning something like results.name and results.email, then the columns need to be configured with the corresponding Data element names. (see the attached screenshot)
To bind this data to a local variable, simply bind the Service Data Table to a list variable with matching elements. (see the attached screenshot) Be sure that the fields on the table, such as Output Text or Text control, are not bound to any variable.
Then you will be able to use the getData() method. For instance, in my Test HHS, the following returns the bound object when called from the browser console based on the default Service Data Table name:
Stephen P.Prashant TiwariDecember 7, 2016 at 8:20 am #3254
This is exactly how I did my set up but it still won’t load it with the variables bound to table.
Are you saying that I need to call getDate() method and then only the bound variable would get updated ?Do you mind taking a look at the code export I sent to you earlier on ftp and guide me what I am doing wrong ?The test Human service has this implementation.
Thanks so much.SPARK SupportDecember 8, 2016 at 5:10 pm #3259
As odd as it may seem, with a Service Data table, you need to have the binding cleared from the two Output Text controls, and only testVar bound to the table. Then the following will work from the console:
Stephen P.Prashant TiwariDecember 9, 2016 at 1:32 pm #3264
Alright I removed the data binding from two output text controls and did :
and also me.getData() on Data loaded on the table.
But that still does not update binding on the variable bound to control.That is – it never gets updated with the data returned from my Ajax Service.SPARK SupportDecember 9, 2016 at 3:29 pm #3265
I can access the variables with the following code in the console:
var sdt = page.ui.get(“AZL_Sparks_Template1/Service_Data_Table1”);
var data = sdt.getData();
Stephen P.Prashant TiwariDecember 29, 2016 at 12:52 pm #3386
Apologies for not explaining this properly but all I want to do is to save the data returned by Ajax service bound to data table to a variable.
Are you saying I cannot do that without calling a js function ?SPARK SupportDecember 30, 2016 at 10:57 am #3394
The Service Data Table is intended to display data retrieved from a service. After further research, I have found that the control will return an array object from getData() with or without the binding. This is because the control ignores the binding on the General configuration tab.
We will be modifying the article for the Service Data Table to state the control should not be bound along with the opening note: “The Service Data Table must specify an AJAX service that returns the data that will be displayed in the table.”
Stephen P.Stuart JonesApril 27, 2017 at 8:21 am #4234
I have been playing with the Service Data Table. Like Prashant, I could not get the data returned by the service to show up. After reading the above, I bound my table control to an appropriate business object – even though the documentation for Service Data Table (in the first paragraph) specifically says NOT to do this:
“The Service Data Table control, similar to the Table control, allows you to create a repeating table. The Service Data Table must specify an AJAX service that returns the data that will be displayed in the table. For this reason, the Service Data Table should never be bound to a variable.”
Once I had done this and set up my (unbound) columns appropriately, it worked just fine – and I did not need any of the JS code suggested above.
I think that the documentation for the Service Data Table needs to be clarified to describe where binding is necessary and where it is not appropriate.
Stuart…SPARK SupportApril 27, 2017 at 10:55 am #4240
The reason that the documentation says not to bind a variable to the Service Data Table (SDT) is because the SDT does not load the bound list object. There is an underlying substitute list that the results of the AJAX service are loaded into.
To demonstrate this, add a Data control to your test harness. Bind the Data control to the same list variable that you are using for the SDT. Run your service and open the console, set a variable equal to the SDT and Data control. Then getData() from the Data control. You will notice that the list is empty.
Further, if you inspect the context binding for each object, you will see that the SDT does not contain a Bound Object, whereas the Data control does.
You must be logged in to reply to this topic.