As the title says, Im trying to remove a row from my grid without it affecting the datasource. The reason for this is that I have a list of ACTIVE users and if one is updated to be INACTIVE I need to remove it from the grid.
Things I've tried in the dataSource requestEnd(), if the type is an update, and the response object is inactive:
1) Remove it from the datasource. This does not work, becuase the next DS sync thats run, calls the destroy method on the deactivated record
Any advice would be appreciated.
Thanks and Kind Regards,
5 Answers, 1 is accepted
Thank you for the details.
Based on the description I can assume that the filter approach will be the best one as it will use a built-in API.
I will be expecting the additional details.
I've been trying to implement the filter in different ways, but the only way it works if I include it when initializing the dataSource. I also cannot duplicate it in the kendo dojo :(.
The fields in my Grid are "name" & "status", both have string values.
In the requestEnd of the DS, I run this:
But any time I try to execute the filter(), or even if the filter is in place (on initialization) and I clear it, I get the JS error "Uncaught TypeError: Cannot read property 'status' of undefined"
I tried to monitor whats happening using the change event on the grid, but it was never triggered.
My name is Alex and I will take over this thread while my colleague Stefan is away.
It seems to me that the best approach here is to have an initial filter if you would like to set the default view for the users to see active items only. I understand that you have already tried that and got an error but I am not able to reproduce such error when I test in a similar scenario as I imagine you have on your hands. It would be most helpful if you let me know what are the differences between the Dojo below and the implementation of your project:
There are few things that can go wrong so it would be best to get the complete picture so we can provide you with the most appropriate advice.
On a side note, unless there are other statuses, I feel that the best approach would be to have the "status" field as a boolean instead of a string.
Look forward to hearing back from you.
My apologies for leaving this thread so long, but some other functionality had been moved up the priority list. I came back to this issue today and was actually able to solve it.
Its a little hard to explain, but I'll do my best.
The example I posted previously was a shortened version of my code, the full snippet is as follows
If you look at line 2, there's and 'e.response.status' field Im checking which indicates a successful response from the server, this was the status that was undefined whenever I ran the filter, not the 'status' field within the data.
I found this by putting a console log in the requestEnd and noticed that another request of type 'read' was ending after the filter was applied. The object in this second request end did not contain a 'response' object, and therein lied my error.
I really appreciate your time and effort and Im sorry it was a waste.
Thank you for your feedback. We are pleased to hear it is all sorted now.
A "console.log()" can be a man's best friend, indeed. I wanted to just share the requestEnd API reference for completeness: