Using VS2010 ASP.NET 11.2 controls.
I'm trying to figure out how to do the client side scripting stuff.
I'm able to wire up a button click event to some javascript.
Seems like I can get access to the WebHierarchicalDataGrid, it is not null.
Several postings talked about getting access to the gridView so they can then find the active cell and then the active row. I'm hoping to set the value in a cell this way.
When I try to get the gridView I get an exception "Object doesn't support property of method get_gridView".
<script language="javascript" type="text/javascript">
function DeactivateNow() {
var grid = document.getElementById("MainContent_WebHierarchicalDataGrid1");
var gridView = grid.get_gridView(); //.get_behaviors().get_activation().get_activeCell().get_row();
alert("Deactivated");
}
</script>
Any idea of why this does not work for me??
Thanks,
Brian.
Hello demoend ,
When using a template column you’ll notice that when you get the value of the cell it will contain the html representation of a button. It’s not recommended to override this value. Instead you could use a hidden column that will contain the Boolean data you need. It can be a standard data field which you can update as any other. Set the Hidden field for that field to true and it won’t be visible on the client but you can still access and update its value. I’m attaching a slightly modified sample for your reference.
Let me know if you have any further questions regarding this.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Maya,
Now I can get the active cell based on your sample code. Thanks!
Yes, I am using some template columns.
Now, I'd like to change the value of the cell. In my column I have a button and it's enabled property is tied to the value of the cell, a boolean. This seems to work fine to enable and disable the button.
However, in the javascript code when I try to set the value of the cell, the button disappears and the value in the database never gets updated. The text then says 'false' in the cell.
How can I set the value of a cell when using templates?
Are you using a template columns containing a button for the child band? Try getting the active cell with the following line:
var activeCell = grid.get_gridView().get_behaviors().get_activation().get_activeCellResolved();
I’m also attaching a working sample for your reference. Let me know if you need further assistance with this.
OK, so now I can access the gridView, thanks!
However, I'm not able to get the cell of the button I just clicked on.
In the behaviors of the grid I have the Activation turned on and the Selection turned on.
When I click on the button the whole row is selected, the client side javascript is called.
I am able to access the activation object when I call the get_activation(). However, if I then try to get the active cell via the code below, it is null.
var activeCell = grid.get_gridView().get_behaviors().get_activation().get_activeCell();
Is there something else I need to enable?
Thank you fo posting in our forum.
You can get the grid element with the $find(“gridId”) method and from there you have access to the get_GridView and other methods native to the grid. For example:
function BtnClick() {
var grid = $find("WebHierarchicalDataGrid1");
var activeRow = grid.get_gridView().get_behaviors().get_activation().get_activeCell().get_row();
Let me know if you have any further questions or concerns regarding this.