public static void init() { ContactsEditorViewModel vm = new ContactsEditorViewModel(); OrganizationServiceProxy.GetUserSettings(); // Data Bind Grid List <Column> columns = GridDataViewBinder.ParseLayout(",entityState,20,First Name,firstname,200,Last Name,lastname,200,Birth Date,birthdate,200,Account Role Code,accountrolecode,200,Number of Children,numberofchildren,100,Currency,transactioncurrencyid,200,Credit Limit,creditlimit,100,Gender,gendercode,100,Owner,ownerid,100"); // Set Column formatters and editors columns[0].Formatter = delegate(int row, int cell, object value, Column columnDef, object dataContext) { EntityStates state = (EntityStates)value; return(((state == EntityStates.Changed) || (state == EntityStates.Created)) ? "<span class='grid-edit-indicator'></span>" : ""); }; // First Name Column XrmTextEditor.BindColumn(columns[1]); // Last Name Column XrmTextEditor.BindColumn(columns[2]); // Birth Date Column XrmDateEditor.BindColumn(columns[3], false); // Account Code Column XrmOptionSetEditor.BindColumn(columns[4], "contact", columns[4].Field, true); // Number of Children Column XrmNumberEditor.BindColumn(columns[5], 0, 100, 0); // Currency Column XrmLookupEditor.BindColumn(columns[6], vm.TransactionCurrencySearchCommand, "transactioncurrencyid", "currencyname", ""); // Credit Limit Column XrmMoneyEditor.BindColumn(columns[7], -10000, 10000); // Another optionset XrmOptionSetEditor.BindColumn(columns[8], "contact", columns[8].Field, true); // OWner Column XrmLookupEditor.BindColumn(columns[9], vm.OwnerSearchCommand, "id", "name", ""); // Create Grid GridDataViewBinder contactGridDataBinder = new GridDataViewBinder(); Grid contactsGrid = contactGridDataBinder.DataBindXrmGrid(vm.Contacts, columns, "container", "pager", true, false); //contactGridDataBinder.BindClickHandler(contactsGrid); // Data Bind ViewBase.RegisterViewModel(vm); Window.SetTimeout(delegate() { vm.Init(); }, 0); }
private static void InitLocalisedContent() { Dictionary <string, string> parameters; string id; string logicalName; int pageSize = 10; #if DEBUG id = "3D5A7E01-0B3F-E811-A952-000D3AB899D0"; logicalName = "account"; parameters = new Dictionary <string, string>(); #else parameters = PageEx.GetWebResourceData(); 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); jQuery.Window.Resize(OnResize); vm = new ContactsViewModel(parent, pageSize); GridDataViewBinder contactsDataBinder = new GridDataViewBinder(); List <Column> columns = GridDataViewBinder.ParseLayout(ResourceStrings.LastName + ",lastname,200," + ResourceStrings.FirstName + ",firstname,200," + ResourceStrings.PreferredContactMethodCode + ",preferredcontactmethodcode,120," + ResourceStrings.CreditLimit + ",creditlimit,120"); contactsGrid = contactsDataBinder.DataBindXrmGrid(vm.Contacts, columns, "container", "pager", true, false); foreach (Column col in columns) { switch (col.Field) { case "preferredcontactmethodcode": XrmOptionSetEditor.BindColumn(col, "contact", "preferredcontactmethodcode", true); break; case "firstname": case "lastname": XrmTextEditor.BindColumn(col); break; case "creditlimit": XrmMoneyEditor.BindColumn(col, 0, 1000000000); break; } } ViewBase.RegisterViewModel(vm); OnResize(null); jQuery.OnDocumentReady(delegate() { 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(); }); }
public static void SetUpGrids(ScheduledJobsEditorViewModel vm) { // Create Scheduled Jobs Grid GridDataViewBinder jobsDataBinder = new GridDataViewBinder(); List <Column> jobCols = GridDataViewBinder.ParseLayout("dev1_name,Name,300,dev1_recurrancepattern,Pattern,300,createdon,Created On, 300"); jobsGrid = jobsDataBinder.DataBindXrmGrid(vm.JobsViewModel, jobCols, "jobsGrid", "jobsGridPager", false, false); GridDataViewBinder bulkDeleteDataBinder = new GridDataViewBinder(); List <Column> bulkDeleteCols = GridDataViewBinder.ParseLayout("name,Name,300,asyncoperation_statuscode,Status,100,asyncoperation_postponeuntil,Next Run,150,asyncoperation_recurrencepattern,Pattern,150,createdon,Created On,150"); bulkDeleteJobsGrid = bulkDeleteDataBinder.DataBindXrmGrid(vm.bulkDeleteJobsViewModel, bulkDeleteCols, "bulkDeleteJobGrid", "bulkDeleteJobGridPager", false, false); // Load first page vm.JobsViewModel.Refresh(); }
public static void init() { ContactsEditorViewModel vm = new ContactsEditorViewModel(); // Data Bind Grid List <Column> columns = GridDataViewBinder.ParseLayout("entityState,,20,firstname,First Name,200,lastname,Last Name,200,birthdate,Birth Date,200,accountrolecode,Account Role Code,200,numberofchildren,Number of Children,100,transactioncurrencyid,Currency,200,creditlimit,Credit Limit,100"); // Set Column formatters and editors columns[0].Formatter = delegate(int row, int cell, object value, Column columnDef, object dataContext) { EntityStates state = (EntityStates)value; return(((state == EntityStates.Changed) || (state == EntityStates.Created)) ? "<span class='grid-edit-indicator'></span>" : ""); }; // First Name Column XrmTextEditor.BindColumn(columns[1]); // Last Name Column XrmTextEditor.BindColumn(columns[2]); // Birth Date Column XrmDateEditor.BindColumn(columns[3], false); // Account Code Column XrmOptionSetEditor.BindColumn(columns[4], "contact", columns[4].Field, true); // Number of Children Column XrmNumberEditor.BindColumn(columns[5], 0, 100, 0); // Currency Column XrmLookupEditor.BindColumn(columns[6], vm.TransactionCurrencySearchCommand, "transactioncurrencyid", "currencyname", ""); // Credit Limit Column XrmMoneyEditor.BindColumn(columns[7], -10000, 10000); // Create Grid GridDataViewBinder contactGridDataBinder = new GridDataViewBinder(); Grid contactsGrid = contactGridDataBinder.DataBindXrmGrid(vm.Contacts, columns, "container", "pager", true, false); // Data Bind ViewBase.RegisterViewModel(vm); }