I have a WHDG on my page and I am trying to resolve which cell the user clicks on.
I enabled activation on my grid, and set a clientside event where i can see what is clicked from javascript. I also added a eventhandler for Activation.ActiveCellChanged to handle the event server side, but it never gets called.
How can I have a event fired server side with the new selected cell?
Hi Dotcomdist,
You could try setting AutopostbackFlags on either Activation or Selection to true to have the server side event fire immediately after the client side event. Whether it is async or full postback is controlled by EnableAjax of the grid itself.
regards,
David Young
AgentD5,
Thanks for the reply. I have the post back working for client and server side now. (Oddly it worked for selection but not activation using the same steps)
But I am now trying to limit the client-side event to only fire for certain columns. I assume this needs to be done in the JavaScript function but I can't seem to resolve the column key for the selected cell's column.
Ok here's where I'm at:
I have a WHDG on my page, I'm trying to make it so that when a user clicks on a cell, if it is a certain column, it will post back to the server with an event. In that event I would like to get the values of fields in the row of the selected cell as well as which column was selected. With this data I will be loading information into another grid.
My issues:
With activation I can on the client side retrieve the column key and only postback on certain columns. But on postback the server side event is never fired.
With selection I can't seem to find how to retrieve the column key to do selective postback, but on postback the server side event is fireing. However I also don't seem to be able to retrieve the value of the selected cell, it's row, or its column from the arguments passed this event.
I also attempted to bind a custom event to the cell during InitializeRow but found no event exposed at the cell level to allow me to bind my own events to selection of the cell.
Please advise me on how I can go about adding this funcationality to my grid.
Since it has been a few days I wanted to follow up with the progress I've made.
AgentD5's support helped me do selective postbacks from client side events, but I'm still stuck trying to retrieve data on the server side event.
inside my server side cellSelectionChanged Event, if i do
SelectedCellCollection scc = e.CurrentSelectedCells;
I can see during debugging that it contains _idPairs which has a rowIDPair and ColumnIDPair which have the column number and row number of the selected cell, but I can not find a way to access this data in code.
I also tried to do:
GridRecordItem gri = e.CurrentSelectedCells[0];
But that always returns null and trying to get the item at Index 1 results in Array out of bounds.
Please advise how i can get information about the selected cell from the CellSelection Event.
Excellent, the above code did indeed allow me to limit my postbacks based on column with the addition of this code:
var key = column.get_key(); if (key == 'name') { __doPostBack('<%= Report_Grid.UniqueID %>', ''); }
If i can just figure out how to get the column name, and records from the selected field's row in the server side event I'll be able to finish.
Protected void Report_Grid_CellSelectionChanged(object sender, Infragistics.Web.UI.GridControls.SelectedCellEventArgs e)
Hi,
If you want to get the column of a newly selected cell in the event, here is the code.
var cell = e.getSelectedCells().getItem(0);
var col = cell.get_column();
var row = cell.get_row();
Hopefully this helps you with getting postback when you want it.
regards,Dave Young