How to access to my Grid in Dynamic CRM365 View - dynamics-crm

I am working on Dynamic CRM365 plugin, in my entity view, I need to know which item has been selected, before I use DOM to detect, however, I can't pass the certification, because all DOM access are risk and need to be replaced, therefore, I checked Xrm.Page.getControl and Xrm.Page.ui.controls, but no luck.
I passed Xrm.Page.getControl("ssl_notesforsigns") or Xrm.Page.getControl("ssl_notesforsign") => return null
I call Xrm.Page.ui, ui = null.
Any idea how to get grid by code?
Thanks

It is good to hear that you no longer want to access the DOM. As you say, that is entirely unsupported.
What is the name of the subgrid on your form? If you go to a form editor and look at the properties for the subgrid, you will see the name (I am guessing that it is not called ssl_notesforsigns). This name is the one you should use, and it can be used when calling Xrm.Page.getControl("namehere") to get your grid context.
Xrm.Page has been deprecated (even though you can still use it). Instead, you should get a reference to your grid context through the execution context. See Client API grid context. For code executing on a form event, you can get your grid context through the form context as follows:
var formContext = executionContext.getFormContext(); // get the form Context
var gridContext = formContext.getControl("namehere"); // get the grid context
When you have a reference to your grid context, you can get the selected rows using getSelectedRows():
var allSelectedRows = gridContext.getGrid().getSelectedRows();

Related

Selecting a KendoUI TreeView That Does Not Have An ID

In KendoUI, how do I select a treeview element if it does not have an ID? Like by the style class or something.
I am writing an MVVM application and there are 2 tabs in a kendo tab strip with each containing a treeview. On selecting one tab, I want it's checkboxes to be updated based on what checkboxes were checked in the other tab and then I want to also call updateIndeterminate() on the treeview it contains within it.
Now, since I am using MVVM, I don't want to access the treeview by it's id. All I can find online on searching is $("#treeView") and in the Telerik forums, the example to call updateIndeterminate() is also this -
var treeview = $("#treeview").data("kendoTreeView");
treeview.updateIndeterminate();
Am I missing something here? I wonder why it's so hard to find.
I suppose the reason why it's hard to find is that it goes against the idea of declarative initialization and the separation of view and model. Your code is not supposed to interact with the widget itself. Instead, all your logic should be wired up in your view model which is bound to the UI.
You can certainly find it without an id, e.g. with something like this:
var treeView = $("ul[data-role=treeview]").first().getKendoTreeView();
or by using the .k-treeview class, but I wouldn't recommend it. If you really need to access it in code, you should give it an id.

Kendo UI Cascading Combobox - Check if initialised

I am using the Kendo UI Cascading combo boxes in an MVC 4 application. The source is too complex to post here, however it follows exactly the same structure as the MVC demo on the Kendo UI site (http://demos.kendoui.com/web/combobox/cascadingcombobox.html).
Occasionally I am getting the exception below, I assume this is because the page isn't fully loaded and the user has tried to interact with the page, therefore causing the combo to attempt to submit an AJAX request to get it's data.
Microsoft JScript runtime error: Cannot call method 'value' of kendoDropDownList before it is initialized
Is there a correct way of checking whether Kendo controls are fully initialised ? If not how can I catch this exception ?
Thanks, Jon.
Make sure load the combo box before you call
var val = $("#yourCombobox").value();
if your combobox isn't initialize it gives undefined as the result.
Load the main combo at the $(document).ready() function and then the onchange even of that combo get the value and load the next combo.

Linq2SQL and IQueryable

Still new to LINQ2SQL so please forgive my ignorance ...
I have one user component which includes one Textbox and one button. The component is used as a generic ListOfValue Filter.
The component has one function to set a IQueryable which is passed to a form that is opened when the user clicks a button on the control.
The form consists of a grid (c1flexgrid) which is filled with the data from the IQueryable. There is a bindingsource on the form that gets the IQueryable as datasource.
The user can select inside the grid and after he selected an entry the dialog is closed and the selected row (or better the selected LINQ2SQL object from the row) is passed back to the control.
On this control i want to show one specific field out of that selected object. The name of that field is passed in to the user control as string.
My problem is, i don't know how to get that field data from an "generic" LINQ2SQL object.
In debugger i can see, that the selected object is of a specific enity type (corresponding to the query)
Probably somthing similar to
Workaround for lack of 'nameof' operator in C# for type-safe databinding?
but just the opposit way :)
Any help would be very welcome
I'm assuming in your IQueryable you don't know at design time the type T. If this is correct, you need to use reflection to get the value you want.
var value = typeof(T).GetProperty("MyField").GetValue(instance, null);
Alternatively, cast the instance to a common base type that implements your field.
CommonBase castInstance = (CommonBase)instance;
var value = castInstance.MyField;

Telerik RadGrid GridTemplateColumns programmatically

I need to make multiple RadGrids with editable columns throughout them. I understand how to make bound columns and make template columns but i do not know how to place Textbox's and Dropdownlists inside of those template columns.
string templateColumnName = "ContactName";
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.ItemTemplate = new MyTemplate(templateColumnName);
templateColumn.HeaderText = templateColumnName;
what do I do after this.
You should instantiate the desired webcontrol within the container. This happens in the InstantiateIn method. I'd recommend that you examine this link:
Programmatic creation
If you need more info, you can also examine this one:
Creating Web Server Control Templates Programmatically
Let us know if you have any specific question about that.

XPages - Bind Document Data Source in a embedded Custom Control

I created a custom control that is binded to a a Domino Document data source. I embedded it in a page so that I can display it in a Dojo dialog. It has 2 properties: dialogId and docId. The document data source's Document ID property is set to compositeData.docId. In the page, I set the docId property to a viewScope variable, that will be set when an entry in a view is clicked. What I want to accomplish is that the dialog will display the document that the current view entry (that was clicked) represents. But it seems that the compositeData.docId is not set on partial or even full refresh. Is there a way to do this that the custom control will be binded to the document? I need to have this binding so that I can easily do a server-side validation when I submit the dialog. Or if there is another way, can you also put it here? Thanks a lot!
set the datasource as the document, and then edit mode, then you have a place to compute the doc id, i usually compute the doc id to a viewScope, that i set when i click the item in the repeat control
More details here.
I would prefer the DocId to be transfered via the custom control parameters rather than a Scope variable. Using the Scope breaks the custom control design principle of being self contained. You can use the yourCC.PropertyMap to actually update a value, so the hand over of the parameter will work - of course your control then needs to be refreshed so the data source is recomputed. Hope that helps.

Resources