PN03
PN03

Reputation: 85

How to filter REST control based on dojo grid selection?

On an Xpage I have two REST controls that populate two enhanced dojo data grids. One is populated with companies, the other I would like populated with the contacts of the selected company. I am able to select a company and display the UNID of that document in a field on the xpage. I am having difficulty filtering the contact grid based on that UNID. What is the best way to do that? Below is what I have tried

Populate the ParentID field with the selected doc UNID using (CSJS):

var grid = arguments[0].grid;
var index = arguments[0].rowIndex;
var item = grid.getItem(index).attributes;
XSP.getElementById("#{id:ParentID}").innerHTML = item.companyLink;
XSP.partialRefreshGet("#{id:contactListPanel}")

Retrieve the UNID from Parent ID and use in the keys parameter of the contact REST control using (SSJS):

getComponent("ParentID").getValue()

It looks like the contact grid is refreshing when a company doc is selected, however all the contacts for all companies appear in the contact grid no matter what company is selected.

Upvotes: 1

Views: 131

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30970

Probably, ParentID field doesn't get submitted to server and isn't available as parameter for REST service.

Transfer company's UNID as parameter in partialRefreshGet() instead

XSP.partialRefreshGet("#{id:contactListPanel}", 
                      {params: {'unidCompany': item.companyLink}})

Read the parameter on server side with

param.unidCompany

and use it as parameter for REST service.

Upvotes: 0

Related Questions