How to add a condition to a column filter

How to add a condition to a column filter

TomBajzekTomBajzek Posts: 164Questions: 37Answers: 1

I have a datatable where several columns have column filters implemented by a select element populated with the actual values found in that column. The filters are implemented entirely in Javascript, modeled on the DataTables documentation and examples. I need to exclude some of the values in one column based on a condition that is in a different table. To be clearer about this, I need to exclude people from my filter who are marked as inactive, which information is in a separate table that is unrelated, and in a different database.

To elaborate a bit more, the primary table is a table of tasks, and the originator is a field in the tasks table. All of the properties of originators, including the activity/inactivity are in a table of users in a database of userAttributes. I need to implement a column filter for the originator column based on the activity field of the originator as recorded in the table in the userAttributes database. The userAttributes database is used by more that a half dozen apps, so it is not really feasible to move the originator's activity status into the tasks database.

Based on my past experience with DataTables, I think I could figure out a way to do this if both tables of interest were in the same database, but in this case they are not, and I have't been able to visualize a reasonable-looking way to do this. Can someone provide a suggestion? ( I don't want to build a piece of code that is uglier than necessary. )

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    It sounds like you just need another ajax call to get the information from that active/inactive table before you create your select elements. That way, you can parse the returned user state and remove/add options to the select accordingly.

    Colin

  • TomBajzekTomBajzek Posts: 164Questions: 37Answers: 1

    Colin,

    So, in the Javascript, I'll make an Ajax call to fetch just the active users, and then where I compute the filter, I'll exclude the originators who aren't in the list of active users. I just wasn't putting the parts together correctly until I got your suggestion.

    Thanks for the helpful clarification,
    Tom

This discussion has been closed.