Hi, I am binding WebExplorerBar control to xml and in ItemBound event I would like to access the dataItem object to get all the attributes for the xml element and store them as Json string in "value" field for the item. when user clicks on an item, I would like to get that data and then decide which page the user should navigate to, dynamically. Please let me know.
Thanks,
Rama
Hi Rama,
take a look at the data binding sample located here: http://samples.infragistics.com/2010.3/WebFeatureBrowser/srcview.aspx?path=WebExplorerBar/WebExplorerBarDataBinding.src&file=WebExplorerBarDataBinding.aspx&font=3
You have to specify explorer bar item bindings so that XML data goes to the right explorer bar item field.
On the client side you have to subscribe for ItemClick:
<ClientEvents ItemClick="ItemClickHandler" />
and you can do the following:
function ItemClickHandler(sender, args) { var value = args.getExplorerBarItem().get_value();
var object = eval(value); // evals the JSON string you have built
window.open(object.navigateUrl, '_blank'); // opens the desired URL in a new window, check the JS API for window.open(). }
Hope this helps.
Lubomir
I think I didn't explain the question clearly. in the ItemBound SERVER-SIDE event, I want to access the xml element that is bound to the control through the "e.ExplorerBarItem.DataItem". if I can get access to it, then I can get all attributes for that element and convert them into a Json string and save it in the value field. once that is done, I can access the value in ItemClick handler like you said. Issue here is that when I try to get the "dataItem" object, I am not able to cast it to the right type to extract values from it. this is very common when binding to Gridview control if I bind it to a collection of objects, I can get a reference to the object in rowdatabound event. I am trying to do something similar here, but it is not working.
I don't want to store my custom attributes in navigateUrl / Tooltip / Target fields, they are not the right place for it, that's why I want to save it as a Json string in value field in ItemBound event. I can't put the Json in Xml directly, because it will invalidate the xml because of the special characters. hope it is clear.