We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Multiple Json Object as Table

Thread ID:

Created:

Updated:

Platform:

Replies:

150436 Jan 7,2020 11:51 AM UTC Jan 10,2020 06:23 AM UTC JavaScript - EJ 2 5
loading
Tags: DropDownList
Deepak
Asked On January 8, 2020 05:12 AM UTC

How to add multiple json object and use predicate for and and or condition with join table

json data: {EMPLOYEE:[ {EMPID:1, NAME:DEEPAK}, {EMPID:2, NAME:JAIN}, {EMPID:3, NAME:SATISH}],              
                   SALARY:[ {EMPID:1, SALARY:20000}, {EMPID:2, SALARY:30000}, {EMPID:3, SALARY:35000}]

1. I want to fetch empid 1 salary with datamanger where predicate condition
2. I want to fetch salary for empid 1 or 3
3. I want to fetch salary for empid 1 and 3

make a query like

from Employee where (id=1 or id=2) and (salary=35000 or salary=20000)


Prasanna Kumar Viswanathan [Syncfusion]
Replied On January 8, 2020 02:01 PM UTC

Hi Deepak, 
 
Thanks for contacting Syncfusion support. 
 
Query : How to add multiple json object and use predicate for and and or condition with join table 
 
By default grid and datamanager only deals with array of JSON data. But the given data is in the object format, not a valid json array. if you bind JSON array to the grid or DataManager, you can able to filter the data using filterSettings.columns and query.  
 
Please refer the below documentation for DataManager query and filterSettings.columns    
 
 
          
Please get back to us if you need further assistance. 
 
Regards, 
Prasanna Kumar N.S.V 
 


Deepak
Replied On January 9, 2020 05:09 AM UTC

Hi Prasanna,

I have not mentioned that I using datamanager with Grid. My requirements are different with your solution provided.


I am cascading to dropdowns with third json

dropdown 1 json : [{HQ_ID:1, HQ_NAME: "Agra"},
{HQ_ID:2, HQ_NAME: "Delhi"}]


dropdown 2 json : [{EMP_ID:1, EMP_NAME: "DEEPAK"},
{EMP_ID:2, EMP_NAME: "PRADEEP"}]


third json: [{empid_1: 1, empid_2: 0, hqid:1}, {empid_1: 0, empid_2, hqid: 2}]

I want to cascade a dropdown with this scenerio using predicate

query should be like this

where (empid_1 =  EMP_IDor empid_2 = EMP_ID) and hqid= HQ_ID



Sureshkumar P [Syncfusion]
Replied On January 9, 2020 11:47 AM UTC

Hi Deepak, 
 
We have checked the reported requirement. We prepared a cascading sample with a predicate query for filtering more than one field. Kindly refer the below code, 
 
var predicate = new ej.data.Predicate('StateId', 'startswith', stateObj.value, true);  
       predicate = predicate.or('StateName', 'contains', stateObj.value,true); 
 
We created a sample based on your requirement. please find the sample here: https://stackblitz.com/edit/iwq5d6-h898t6?file=index.js  
 
Regards, 
Sureshkumar P 


Deepak
Replied On January 9, 2020 12:23 PM UTC

Thanks for your reply.

A single level predicating is fine but my requirement is more complex than your solution.

I want something like this
var predicate = new ej.data.Predicate('EMP_ID_1', 'equal', profile.EmpId, true); 
predicate.or('EMP_ID_2', 'equal', profile.EmpId, true);
predicate.or('EMP_ID_3', 'equal', profile.EmpId, true);
predicate.or('EMP_ID_4', 'equal', profile.EmpId, true);

var predicate2 = new ej.data.Predicate(predicate); 
predicate2 = predicate.and('StateId', 'equal', stateObj.value,true);


so the query will be like this where (emp_id_1=1 or emp_id_2=1 or emp_id_3=1 or emp_id_4=1) and state_id = 4




Sureshkumar P [Syncfusion]
Replied On January 10, 2020 06:23 AM UTC

Hi Deepak, 
 
Thanks for your update 
 
We have checked the reported requirement. We would like to let you know that you can more than one query in the predicate option as mentioned in the code snippet, 
 
var predicate = new ej.data.Predicate('StateId''startswith', stateObj.value, true); 
predicate = predicate.or('StateName''contains', stateObj.value, true); 
predicate = predicate.or('CountryId''contains', stateObj.value, true); 
 
var tempQuery1 = new ej.data.Query().where(predicate); 
 
var tempQuery1 = new ej.data.Query().where(predicate); 
 
And pass the predicate in the where query.to get rid of your facing issue. 
 
Regards, 
Sureshkumar P 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon