I am opening Silverlight application from contextual custom tab's custom ribbon button.
In this case Xrm.Page.ui and Xrm.Page.data are null as I am not showing Silverlight app as iframe on entity form. Please read Updated post at (http://crm2001andsilverlight.blogspot.com/2011/04/accessing-selected-entity-ids-from.html")
In order to access selected sub grid Ids in Silverlight .
private List<Guid> GetSelectedRecords()
{
List<Guid> selectedIds = new List<Guid>();
HtmlElement gridBodyTable = (HtmlElement)HtmlPage.Window.Eval("dialogArguments.window.document.getElementById(\"gridBodyTable\")");
if (gridBodyTable != null)
{
foreach (var record in gridBodyTable.Children)
{
HtmlElement section = (HtmlElement)record;
if (section.TagName.Equals("tbody"))
{
foreach (var tableRow in section.Children)
{
HtmlElement row = (HtmlElement)tableRow;
if (row.TagName.Equals("tr"))
{
if (tableRow.GetProperty("selected") != null && (bool) tableRow.GetProperty("selected"))
{
var id = tableRow.GetProperty("oid");
if (id != null)
{
selectedIds.Add(new Guid(id as string));
}
}
}
}
}
}
}
return selectedIds;
}
Or if anyone interested only in subgrids html from silverlight app using javascript use
window.dialogArguments.window.document.activeElement.document.body.innerHTML.
Here is another useful link
http://social.microsoft.com/Forums/en/crm2011beta/thread/22d2c422-35c2-43ee-b33a-4bb7f8c36155
In this case Xrm.Page.ui and Xrm.Page.data are null as I am not showing Silverlight app as iframe on entity form. Please read Updated post at (http://crm2001andsilverlight.blogspot.com/2011/04/accessing-selected-entity-ids-from.html")
In order to access selected sub grid Ids in Silverlight .
private List<Guid> GetSelectedRecords()
{
List<Guid> selectedIds = new List<Guid>();
HtmlElement gridBodyTable = (HtmlElement)HtmlPage.Window.Eval("dialogArguments.window.document.getElementById(\"gridBodyTable\")");
if (gridBodyTable != null)
{
foreach (var record in gridBodyTable.Children)
{
HtmlElement section = (HtmlElement)record;
if (section.TagName.Equals("tbody"))
{
foreach (var tableRow in section.Children)
{
HtmlElement row = (HtmlElement)tableRow;
if (row.TagName.Equals("tr"))
{
if (tableRow.GetProperty("selected") != null && (bool) tableRow.GetProperty("selected"))
{
var id = tableRow.GetProperty("oid");
if (id != null)
{
selectedIds.Add(new Guid(id as string));
}
}
}
}
}
}
}
return selectedIds;
}
Or if anyone interested only in subgrids html from silverlight app using javascript use
window.dialogArguments.window.document.activeElement.document.body.innerHTML.
Here is another useful link
http://social.microsoft.com/Forums/en/crm2011beta/thread/22d2c422-35c2-43ee-b33a-4bb7f8c36155
No comments:
Post a Comment