In a grid with a row selected, if a user clicks on another row, is there a way of
cancelling the selection in javascript ? Like in the BeforeRowActivateHandler ?
Thanks
Hello Sam,
samuelburns said:Your code for example has this MyCondition variable - 'what on earth is that for?' one might ask.
When coding an if statement one must have some condition to determine if you wanted to cancel the selection change otherwise how do you perform a decision in code? If your scenario does not allow any selection change at all then you can actively omit that conditional check and simply return true. If there was any misunderstanding because of my conditional check I apologize.
It looks to me like Developer Support should become involved in your scenario and see what is going on with the WebGrid when you want to cancel the selection of a row, they can be contacted here. It could be the version of the NetAdvantage WebGrid you are using or the result of other factors and we should see what is truly happening here.
Hello Thierry,
1) Duly noted.
2) Which threads/topics are you referring to? In an event handler we should always be detecting return true to effectively cancel the event. There are cases where for a particular CSOM object we can set a returnValue variable or a cancelPostBack variable to do the same thing as returning true from the event handler and the value should still be set to true. If you are finding this is not the case, can you cite some examples?
One final answer to this after having to do a lot of work in this area. You need to cancel the BeforeSelectChangeHandler and the BeforeRowActivateHandler events in that order to truly cancel a row selection.
A row being selected and being active are two different things so the first event gets fired first when you select a new row. Regardless of whether you allow or cancel that event, the activation event fires next.
What I do is determine if I'm cancelling in the BeforeSelectChangeHandler routine, and use the same return value in the BeforeRowActivateHandler routine that fires next.
If you don't do this properly you will see that a row stays selected for example, but the active thicker border shows on the row you selected, and now the selected and active row are no longer the same.
I appreciate this response but as the original poster says, there is a lot of information missing from the documentation and even this answer. I'm finding that the documentation does not tell you the trickiness of handling this event. Your code for example has this MyCondition variable - 'what on earth is that for?' one might ask. I'm finding the event fires twice, once with an id of blank to deselect the currently selected row. Regardless of whether I return true or false from this, the event gets fired again with the id populated with the id of the row about to be selected. So in order to truly cancel the event I have to rig up something like what you have in your code so that I can cancel the event twice. In my case I needed to prompt the user to see if they wanted to save changes before permitting the row change so I had to program to avoid the message coming up twice also.
Sam.
Matthew Kraft"]Hello, The UltraWebGrid has a BeforeRowActivateHandler and a BeforeSelectChangeHandler <both on the Client Side Events list> that you can handle and plug in the javascript necessary to accomplish this task... something like: var MyCondition = 0; function UltraWebGrid1_BeforeSelectChangeHandler(gridName, id){ MyCondition += 1; if (MyCondition > 2) { return true; } }
Hello,
The UltraWebGrid has a BeforeRowActivateHandler and a BeforeSelectChangeHandler <both on the Client Side Events list> that you can handle and plug in the javascript necessary to accomplish this task... something like:
var MyCondition = 0;
function UltraWebGrid1_BeforeSelectChangeHandler(gridName, id){
MyCondition += 1;
if (MyCondition > 2) {
return true;
}
2 remarks:
1) searching for the 3 words: cancel row select doesn't return this thread. Searching for: cancelling row selectdoes find this thread. Maybe the search algorithm could be improved a little...
2) I have read in different places (including from Infragistics employees, thread 651) that to cancel a client side event, you use things like "return false;" or "event.returnValue = false;". But here it seems that to cancel the row select, you have to return true. Where is this documented? The help file certainly doesn't specify this in an obvious way.
regards,Thierry