Closed molerat619 closed 6 years ago
setFilter
is used only for "normal" filters, which is why you get the exception telling you that the column does not exist. As documented, firing an event is the correct way of sending a custom filter. As for adding it inside the query parameter, custom filters are used independently of normal column filters, and so can be used even when the user has a generic filter in place, or no filter at all. This means that the query
object will not always be present (i.e it can either be a string, or not exist at all). Admittedly, in your specific use-case it would have been better to treat it as a "normal" filter.
I see. I am using the Eloquent-class which does not take that "external" or independent attribute from the $request. Can I add it to the query, before the filter is sent or do I have to handle it on the server side? If the latter, I would be thankful for a hint on how to do it. Thank you :)
You can add it either on the client side, using the requestAdapter
function, or on the server side, using some simple array manipulation before you pass the request (You might want to consider passing the request to the class from the controller, and not read it directly from the class. This way you don't have to meddle with the core class).
Thank you, that was simple. Here is how I did it:
requestAdapter: function(data){
if(data.employee_id){
data.query.employee_id = data.employee_id;
}
return data;
}
Hey @matfish2 - first of all, thank you so much for this module and all your work. I really appreciate it.
I have been trying to set up a custom filter to use my autocomplete module to find an employee. For that, I have done the following:
employee_id
from thefilterable
array in order to get rid of the default filter control.employee_id
to thecustomFilters
array.this.$refs.taskTable.setFilter({employee_id: value.id});
Now this actually sends out a request, but the employee_id-field is empty and I get the following Error in the console.
Error in setting filter value. Column 'employee_id' does not exist.
(on v-server-table I have set ref="taskTable"). Here is the full Log:If I use
Event.$emit('vue-tables.filter::employee_id', value.id);
instead that sends out a request without error, but it does not put the employee_id inside the query, but on the same level:I am not sure if I am doing it wrong or if it is a bug. Looking forward to your response.