public static void Init() { PageEx.MajorVersion = 2013; // Use the CRM2013/2015 styles vm = new ConnectionsViewModel(); ViewBase.RegisterViewModel(vm); GridDataViewBinder connectionsDataBinder = new GridDataViewBinder(); List<Column> columns = GridDataViewBinder.ParseLayout("Connect to, record1id,250,Role,record1roleid,250"); XrmLookupEditor.BindColumn(columns[1], vm.RoleSearchCommand, "connectionroleid", "name", ""); Grid connectionsGrid = connectionsDataBinder.DataBindXrmGrid(vm.Connections, columns, "container", "pager", true, false); ViewBase.RegisterViewModel(vm); jQuery.OnDocumentReady(delegate() { vm.Search(); }); }
public static void CheckConnectionsCollection(Assert assert) { // Add in the connection Entity connection = new Entity("connection"); connection.SetAttributeValue("record1id", accounts[0].ToEntityReference()); connection.SetAttributeValue("record2id", accounts[1].ToEntityReference()); OrganizationServiceProxy.Create(connection); assert.Expect(1); Action done = assert.Async(); ConnectionsViewModel vm = new ConnectionsViewModel(accounts[0].ToEntityReference(), null); vm.Connections.OnDataLoaded.Subscribe(delegate(EventData data, object args) { assert.Equal(vm.Connections.GetLength(), 1, "Only 1 connection"); done(); }); vm.Search(); }
private static void InitLocalisedContent() { Dictionary<string, string> parameters; string id; string logicalName; int pageSize = 10; string defaultView=null; #if DEBUG id = "C489707F-B5E2-E411-80D5-080027846324"; logicalName = "account"; parameters = new Dictionary<string, string>(); #else parameters = PageEx.GetWebResourceData(); // The allowed lookup types for the connections - e.g. account, contact, opportunity. This must be passed as a data parameter to the webresource 'account=name&contact=fullname&opportunity=name id = ParentPage.Data.Entity.GetId(); logicalName = ParentPage.Data.Entity.GetEntityName(); ParentPage.Data.Entity.AddOnSave(CheckForSaved); #endif EntityReference parent = new EntityReference(new Guid(id), logicalName, null); string entities = "account,contact,opportunity,systemuser"; foreach (string key in parameters.Keys) { switch (key.ToLowerCase()) { case "entities": entities = parameters[key]; break; case "pageSize": pageSize = int.Parse(parameters[key]); break; case "view": defaultView = parameters[key]; break; case "category": category = int.Parse(parameters[key]); break; } } // Get the view QueryParser queryParser = new QueryParser(new string[] {"connection"}); queryParser.GetView("connection", defaultView); queryParser.QueryMetadata(); EntityQuery connectionViews = queryParser.EntityLookup["connection"]; string viewName = connectionViews.Views.Keys[0]; FetchQuerySettings view = connectionViews.Views[viewName]; vm = new ConnectionsViewModel(parent, entities.Split(","), pageSize, view); // Bind Connections grid GridDataViewBinder connectionsGridDataBinder = new GridDataViewBinder(); List<Column> columns = view.Columns; // Role2Id Column - provided it is in the view! foreach (Column col in columns) { switch (col.Field) { case "record2roleid": XrmLookupEditor.BindColumn(col, vm.RoleSearchCommand, "connectionroleid", "name,category", ""); break; case "description": XrmTextEditor.BindColumn(col); break; case "effectivestart": case "effectiveend": XrmDateEditor.BindColumn(col, true); break; } } connectionsGrid = connectionsGridDataBinder.DataBindXrmGrid(vm.Connections, columns, "container", "pager", true, false); connectionsGrid.OnActiveCellChanged.Subscribe(delegate(EventData e, object data) { OnCellChangedEventData eventData = (OnCellChangedEventData)data; vm.SelectedConnection.SetValue((Connection)connectionsGrid.GetDataItem(eventData.Row)); }); connectionsGridDataBinder.BindClickHandler(connectionsGrid); // Let's not use a hover button because it get's in the way of the editable grid! //RowHoverPlugin rowButtons = new RowHoverPlugin("gridButtons"); //connectionsGrid.RegisterPlugin(rowButtons); ViewBase.RegisterViewModel(vm); OverrideMetadata(); jQuery.Window.Resize(OnResize); jQuery.OnDocumentReady(delegate() { OnResize(null); vm.Search(); }); }
private static void InitLocalisedContent() { Dictionary<string, string> entityTypes; string id; string logicalName; #if DEBUG id = "C489707F-B5E2-E411-80D5-080027846324"; logicalName = "account"; entityTypes = new Dictionary<string, string>(); entityTypes["account"] = "name"; entityTypes["contact"] = "fullname"; entityTypes["opportunity"] = "name"; #else entityTypes = PageEx.GetWebResourceData(); // The allowed lookup types for the connections - e.g. account, contact, opportunity. This must be passed as a data parameter to the webresource 'account=name&contact=fullname&opportunity=name id = ParentPage.Data.Entity.GetId(); logicalName = ParentPage.Data.Entity.GetEntityName(); #endif EntityReference parent = new EntityReference(new Guid(id), logicalName, null); vm = new ConnectionsViewModel(parent, entityTypes); // Bind Connections grid GridDataViewBinder contactGridDataBinder = new GridDataViewBinder(); List<Column> columns = GridDataViewBinder.ParseLayout(String.Format("{0},record1id,250,{1},record1roleid,250", ResourceStrings.ConnectTo, ResourceStrings.Role)); // Role2Id Column XrmLookupEditor.BindColumn(columns[1], vm.RoleSearchCommand, "connectionroleid", "name", ""); connectionsGrid = contactGridDataBinder.DataBindXrmGrid(vm.Connections, columns, "container", "pager", true, false); connectionsGrid.OnActiveCellChanged.Subscribe(delegate(EventData e, object data) { OnCellChangedEventData eventData = (OnCellChangedEventData)data; vm.SelectedConnection.SetValue((Connection)connectionsGrid.GetDataItem(eventData.Row)); }); // Let's not use a hover button because it get's n the way of the editable grid! //RowHoverPlugin rowButtons = new RowHoverPlugin("gridButtons"); //connectionsGrid.RegisterPlugin(rowButtons); ViewBase.RegisterViewModel(vm); OverrideMetadata(); jQuery.Window.Resize(OnResize); jQuery.OnDocumentReady(delegate() { OnResize(null); vm.Search(); }); }