How to use the filter condition of one model to another model

  • 2
  • Question
  • Updated 5 months ago
  • In Progress
I have a model which have filter criteria . some is of type filterable on and some is of type of filterable off. model is added into the table and at one time only 50 records can visible. on the click of load more , more records is visible. After applying the filter, records is recived on the basis of the filter condition.

I want to show the total records on the UI. For example : table is displaying only 50 records. But in the database, 200 records exist according to the filter condition.

How can i show this?

If i will use the aggregate model then i need to use the same filter of account model. But how will we use the same filter condition into the another model.

Thanks
Photo of Geeta

Geeta

  • 440 Points 250 badge 2x thumb

Posted 5 months ago

  • 2
Photo of Matt Brown

Matt Brown, Product Manager

  • 2,106 Points 2k badge 2x thumb
Hi Geeta,

Couple things that may be helpful: 

1. The table component has a pagination property in the composer under "Display" where you can choose how many records you want to display at one time. One option is "Show All", which will show all records in the model.

2. The model has a property called "Max # of records" which lets you decide how many rows you want to bring in at one time. If you delete that, it will return all available records in the database (as long as you don't hit your data source's query limit). 

Do either of those help?  Thanks!
Matt
Photo of Geeta

Geeta

  • 440 Points 250 badge 2x thumb
Hi ,

Thanks for your response. 

1. I want to show only 50 records at a time in the table  and user can use the pagination or load more for getting the records. But On the top of the table , i just want to tell the user about the records which should retrieved w/o limit.

For example : in my org 10000 account records exist. At one time i am displaying only 50 records in a table. But on the above of table i want to show 10000 . So that user can know.

If user apply the filter and then after filter 7000 record should available . then i want to show the 7000 on the above of the table and 50 records in the table and for showing more user can click on the load more button.

Thanks,
Geeta Garg
Photo of Matt Brown

Matt Brown, Product Manager

  • 2,106 Points 2k badge 2x thumb
Ah, ok! Yes, I think you'll need an aggregate model to go and pull that number. How many filters do you have on the list model?

You can 'tie' models together using model actions - model actions have an option to select condition changes as an initiating event, and when that event triggers the action, you can pass in Model A's condition values into Model B's condition as well, using the model conditions merge variable ($Model.ModelName.conditions.0.value). More on condition merge variables here: https://docs.skuid.com/latest/v2/en/skuid/merge-syntax/global-merge-variables.html

And here's our doc on model actions (check out the section on initiating events): https://docs.skuid.com/latest/en/skuid/models/model-actions.html
Photo of Geeta

Geeta

  • 440 Points 250 badge 2x thumb
Thanks for your response.

We have 11 filter condition  in the table. I used the approach which is suggested by you.On the change or activate of model condition, we activated and pass the filter condition value  into the another model using merge syntax.

As of now we are setting the value as {{$Model.VC_OfferRecords.conditions.2.values}}

But in the future if any filter condition is removed or changes the sequence , then we need to update all the condition. Is there any  way to find out the index and then set the value.

I am facing the issue at the time of loading.

1. At the time of loading, may be some of filter is previously selected so it may be show as selected.So how can we activate and set the value into another model?

2. At the time of loading, may be filter is not selected , then  how can we identify the filter is selected or not and pass the value at the time of loading?

Thanks,
Geeta Garg
Photo of Matt Davis

Matt Davis, Employee

  • 1,640 Points 1k badge 2x thumb
Hey Geeta, do you need to show the total number of records available or could you get away with just showing that more records are available? For example, if you have 285 records available do you need to show 285 or can you show 50+, where the + indicates that there are more records available? If you can do that, there's some merge syntax available for canRetrieveMoreRows that is true if a model has more rows available to load. So you could have a Page Title on the model that has something like
VC Offers ({{$Model.VC_OfferRecords.data.length}}{{#$Model.VC_OfferRecords.canRetrieveMoreRows}}+{{/$Model.VC_OfferRecords.canRetrieveMoreRows}})

Initially it would show "VC Offers (50+)", then if they load more it would be "VC Offers (100+)", up until they load everything and it says "VC Offers (285)".
Photo of Geeta

Geeta

  • 440 Points 250 badge 2x thumb
Hi Davis,

I want to show 285 records.

And after applying the filter, if records is exist in the database is 240 then i want to show 240. but in the table , it will show 50 with load more functionality.

Thanks,
Geeta Garg
Photo of Matt Davis

Matt Davis, Employee

  • 1,640 Points 1k badge 2x thumb
Yeah, the ability to handle page load is challenging depending on the version of Skuid you're on. If you're on Spark (12.0+) then it's actually fairly simple to do, but if you're on a prior version then it's more manual to handle.
Photo of Geeta

Geeta

  • 440 Points 250 badge 2x thumb
skuid version is : 11.2.9

How can i handle manually for both condition(Filter is not selected or filter is selected) at loading time?
Photo of Pat Vachon

Pat Vachon, Champion

  • 45,310 Points 20k badge 2x thumb
Hey Geeta,

You can make use of 2 action sequences to get what you're looking for.
  1. A Event Triggered Action Sequence called "On Page Load" that runs on page load to run the "Update Total Records Agg".
  2. A reuseable Action Sequencesequence called "Update Total Records Agg" that contains the Action to update the conditions and query.
Then you'd simply setup Model Action on query for you table details model to call the "Update Total Records Agg" Action Sequence.



Clear as mud?

Photo of Geeta

Geeta

  • 440 Points 250 badge 2x thumb
Hi,

I checked that but i did not get the way the pass model condition into another model.

Can you please share the screenshot?

Thanks,
Geeta Garg
Photo of Pat Vachon

Pat Vachon, Champion

  • 45,310 Points 20k badge 2x thumb
That is done using merge variables. It's as per Matt Brown's instructions above and screenshot below.