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);
        }
Exemplo n.º 2
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();
            }
                                   );
        }
Exemplo n.º 3
0
        public static void init()
        {
            QuoteLineItemEditorViewModel vm = new QuoteLineItemEditorViewModel();

            List <Column> columns = new List <Column>();

            GridDataViewBinder.AddEditIndicatorColumn(columns);


            XrmNumberEditor.BindReadOnlyColumn(
                GridDataViewBinder.AddColumn(columns, "#", 40, "lineitemnumber"),
                0);

            XrmLookupEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, "Existing Product", 200, "productid"),
                vm.ProductSearchCommand, "productid", "name", "");

            XrmLookupEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, "Units", 100, "uomid"),
                vm.UoMSearchCommand, "uomid", "name", "");

            XrmTextEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, "Write-In Product", 200, "productdescription"));

            XrmMoneyEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, "Price Per Unit", 200, "priceperunit"),
                0,
                1000);

            XrmNumberEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, "Quantity", 200, "quantity"),
                0,
                1000,
                2);

            XrmMoneyEditor.BindReadOnlyColumn(
                GridDataViewBinder.AddColumn(columns, "Extended Amount", 100, "extendedamount"));


            GridDataViewBinder contactGridDataBinder = new GridDataViewBinder();
            Grid contactsGrid = contactGridDataBinder.DataBindXrmGrid(vm.Lines, columns, "quoteproductGrid", "quoteproductPager", true, true);

            contactGridDataBinder.BindCommitEdit(vm);

            ViewBase.RegisterViewModel(vm);
            Window.SetTimeout(delegate()
            {
                vm.Lines.Refresh();
            }, 0);
        }
        public static void Init()
        {
            PageEx.MajorVersion = 2013;

            jQuery.OnDocumentReady(delegate()
            {
                ValidationApi.RegisterExtenders();

                // Init settings
                OrganizationServiceProxy.GetUserSettings();
                SimpleEditableGridViewModel vm = new SimpleEditableGridViewModel();

                // Create Grid
                GridDataViewBinder dataViewBinder      = new GridDataViewBinder();
                dataViewBinder.AddCheckBoxSelectColumn = true;
                dataViewBinder.SelectActiveRow         = true;
                dataViewBinder.MultiSelect             = false;
                List <Column> columns    = new List <Column>();
                EditorFactory textEditor = (EditorFactory)Script.Literal("Slick.Editors.Text");

                XrmTextEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Title", 150, "title"));
                XrmTextEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Author", 150, "author"));
                XrmDateEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Published", 150, "publishdate"), true);
                XrmMoneyEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Price", 150, "price"), 0, 100);
                XrmNumberEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Copies", 150, "numberofcopies"), 0, 1000, 0);
                XrmLookupEditorOptions languageLookupOptions =
                    (XrmLookupEditorOptions)XrmLookupEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Language", 150, "language"), vm.GetLanguages, "id", "name", null).Options;
                languageLookupOptions.showImage = false;

                OptionSetBindingOptions formatBindingOptions = new OptionSetBindingOptions();
                formatBindingOptions.allowEmpty            = true;
                formatBindingOptions.GetOptionSetsDelegate = vm.GetFormats;

                XrmOptionSetEditor.BindColumnWithOptions(GridDataViewBinder.AddColumn(columns, "Format", 150, "format"), formatBindingOptions);
                XrmDurationEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Audio Length", 150, "audiolength"));
                XrmTimeEditor.BindColumn(GridDataViewBinder.AddColumn(columns, "Start Time", 150, "starttime"));

                Grid grid = dataViewBinder.DataBindXrmGrid(vm.Books, columns, "booksGridContainer", null, true, true);
                ViewBase.RegisterViewModel(vm);

                Window.SetTimeout(delegate()
                {
                    vm.LoadBooks();
                    grid.ResizeCanvas();
                }, 0);
            });
        }
Exemplo n.º 5
0
        public static void Init()
        {
            vm = new ContactViewModel();

            List <Column> columns = new List <Column>();

            GridDataViewBinder.AddEditIndicatorColumn(columns);

            //Creacion de columnas para el grid
            XrmTextEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, ResourceStrings.FirstName, 200, "firstname"));
            XrmTextEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, ResourceStrings.LastName, 200, "lastname"));

            XrmOptionSetEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, ResourceStrings.PreferredContactType, 200, "preferredcontactmethodcode"), "contact", "preferredcontactmethodcode", false);

            XrmMoneyEditor.BindColumn(
                GridDataViewBinder.AddColumn(columns, ResourceStrings.CreditLimit, 200, "creditlimit"), -1000, 100000000);

            //Montar grid
            GridDataViewBinder contactGridDataBinder = new GridDataViewBinder();
            Grid contactsGrid = contactGridDataBinder.DataBindXrmGrid(vm.Contacts, columns, "container", "pager", true, false);

            contactGridDataBinder.BindCommitEdit(vm);

            contactGridDataBinder.BindClickHandler(contactsGrid);

            ViewBase.RegisterViewModel(vm);
            Window.SetTimeout(delegate()
            {
                vm.Search();
                vm.Contacts.Refresh();
            }, 0);


            /*CAMBIO DE IDIOMA A TRAVES DE JAVASCRIPT*/
            //int lcid = OrganizationServiceProxy.GetUserSettings().UILanguageId.Value;

            //LocalisedContentLoader.LoadContent("fmp_/js/Res.metadata.js", lcid, delegate ()
            //{

            //    ViewBase.RegisterViewModel(vm);
            //});
        }
Exemplo n.º 6
0
        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);
        }