Hello. As I understand it, you can use jQuery to add new "filter lines" in your form (using the append function, for example) and submit this data as string arrays for your action. In the action you go through the arrays with column names and values (maybe also the type, like CONTAINS, DOES NOT CONTAIN, etc.) and generate your query.
To generate new lines, there are some ways:
- Create a new div; create the internal elements and insert them into the div; insert the div into the form.
- Add the div already with the internal elements by inserting direct HTML code (
$("#meuform").append("<div><select...")
).
- Create an action that returns a view with only one filter line, containing select, input, button, etc. Load and load this view via Ajax by inserting it into the form.
- Create a "model" div, containing the filter elements (select, input, etc.), leave it with display:None and to insert a new line in the form, copy the contents of that div (using the html() function, for example).
With these lines created in the form, you submit to your action and there generates the query.
Hello. It’s not very clear what your need is. Could you explain better what you need to do?
– Joel Rodrigues
@Mariane Ribeiro. Hi, if I understand correctly, you have a query and from it you want to add other filter options in this same query.
– Luiz Vichiatto
@Luizvichiatto exact this!! I do not want to filter through a specific object of my database, would have how? I thank you already!!
– Mariane Ribeiro
@Joelrodrigues actually I’m working with other layers within the mvc, With Repository, Dao and the business layer, already understood the concept of MVC there joined more layers and as I am at the beginning gave a complicated, hehe... But so it could be like this, not to complicate, I wanted to know how to make a page to filter activities... Thank you for your attention!!
– Mariane Ribeiro
Let me get this straight. Do you want to have a multi-column combobox of your table and be able to add multiple filters to generate a dynamic query? For example, the user selects NAME and adds a value, then selects CATEGORY and enters another value? In the end it would generate a select of type WHERE CAMPO1 = 'x' AND CAMPO2 = 'y' ...?
– Joel Rodrigues
@Joelrodrigues exactly this! summed up exactly what I need! :)
– Mariane Ribeiro