示例#1
0
 public void AddList(IEnumerable <IIndexableItem> list, FieldConfig indexConfig, string scope)
 {
     DeleteAllOfType(this, scope);
     foreach (IIndexableItem item in list)
     {
         Add(item, indexConfig);
     }
 }
 public QueryBuilder(FieldConfig config)
 {
     _indexConfig = config;
     Select       = new Select
     {
         PageSize = 100
     };
 }
示例#3
0
        public void SqlColumn_WhenColumnIsIgnored_DoesntSetResolver()
        {
            var fieldConfig = new FieldConfig("name");

            fieldConfig.SqlColumn(ignore: true);

            fieldConfig.Resolver.Should().BeNull();
        }
示例#4
0
 public virtual void BuildFieldConfig(FieldConfig fieldConfig)
 {
     if (this.config.TryGetValue(ConfigurationKeys.FIELD_BOOST_MAP, out IDictionary <string, float> fieldBoostMap) &&
         fieldBoostMap.TryGetValue(fieldConfig.Field, out float boost))
     {
         fieldConfig.Set(ConfigurationKeys.BOOST, boost);
     }
 }
示例#5
0
        public void SqlColumn_WithColumnName_SetsColumnName()
        {
            var fieldConfig = new FieldConfig("name");

            var builder = fieldConfig.SqlColumn("productName");

            builder.SqlColumnConfig.Column.Should().Be("productName");
        }
示例#6
0
        public void SqlJoin_WhenFieldResolverIsNull_SetsResolver()
        {
            var fieldConfig = new FieldConfig("name");

            fieldConfig.SqlJoin((join, arguments, context, node) => {});

            fieldConfig.Resolver.Should().Be(DictionaryFieldResolver.Instance);
        }
示例#7
0
 public void Add(IIndexableItem data, FieldConfig config)
 {
     if (null == data)
     {
         throw new ArgumentNullException("data");
     }
     Store.Add(JsonMappingUtils.JsonToDocument(data.GetScope(), data.GetId(), data.GetCreatedByUserId(), data.GetCreatedOnDate(), data.GetData(), data.GetSource(), config));
 }
示例#8
0
        public void SqlColumn_WhenFieldResolverIsNull_SetsResolver()
        {
            var fieldConfig = new FieldConfig("name");

            fieldConfig.SqlColumn("productName");

            fieldConfig.Resolver.Should().Be(DictionaryFieldResolver.Instance);
        }
示例#9
0
        public void SqlColumn_WhenColumnIsNull_UsesFieldNameAsColumnName()
        {
            var fieldConfig = new FieldConfig("name");

            var builder = fieldConfig.SqlColumn();

            builder.SqlColumnConfig.Column.Should().Be("name");
        }
        /// <summary>
        /// 置为新增记录状态
        /// </summary>
        public void SetAddNewStatus()
        {
            Control startCtrl   = null;
            int     minTabIndex = -1;
            bool    firstFlag   = true;

            foreach (Control ctrl in this.propertyPanel.Controls)
            {
                if (ctrl is Label)
                {
                    continue;
                }

                FieldConfig config = (FieldConfig)ctrl.Tag;

                if (ctrl is CheckBox)
                {
                    ((CheckBox)ctrl).Checked = false;
                }

                else if (ctrl is TextBox)
                {
                    if (config.IS_PRIMARY_KEY && config.AUTO_INCREASE)
                    {
                        ctrl.Enabled = false;
                    }
                    else
                    {
                        ctrl.Enabled = true;
                    }
                    ((TextBox)ctrl).Text = "";
                }
                else
                {
                }
                if (firstFlag)
                {
                    if (ctrl.Enabled)
                    {
                        minTabIndex = config.TABINDEX;
                        startCtrl   = ctrl;
                        firstFlag   = false;
                    }
                }
                else
                {
                    if (ctrl.Enabled && minTabIndex > config.TABINDEX)
                    {
                        minTabIndex = config.TABINDEX;
                        startCtrl   = ctrl;
                    }
                }
            }
            if (startCtrl != null)
            {
                startCtrl.Focus();
            }
        }
示例#11
0
        void sourceCtrl_Click(object sender, EventArgs e)
        {
            txtWidth.TextChanged      -= new EventHandler(txtWidth_TextChanged);
            txtHeight.TextChanged     -= new EventHandler(txtHeight_TextChanged);
            txtLocationX.ValueChanged -= new EventHandler(txtLocation_ValueChanged);
            txtLocationY.ValueChanged -= new EventHandler(txtLocation_ValueChanged);

            txtWidth.Text      = ((Control)sender).Width.ToString();
            txtHeight.Text     = ((Control)sender).Height.ToString();
            txtLocationX.Value = ((Control)sender).Left;
            txtLocationY.Value = ((Control)sender).Top;

            txtWidth.TextChanged      += new EventHandler(txtWidth_TextChanged);
            txtHeight.TextChanged     += new EventHandler(txtHeight_TextChanged);
            txtLocationX.ValueChanged += new EventHandler(txtLocation_ValueChanged);
            txtLocationY.ValueChanged += new EventHandler(txtLocation_ValueChanged);

            foreach (Control ctrl in plControls.Controls)
            {
                if (ctrl is TextBox)
                {
                    ((TextBox)ctrl).BackColor = Color.White;
                    ((TextBox)ctrl).ForeColor = Color.Black;
                }
                if (ctrl is CheckBox)
                {
                    ((CheckBox)ctrl).BackColor = Color.Transparent;
                    ((CheckBox)ctrl).ForeColor = Color.Black;
                }
            }

            if (((Control)sender) is TextBox)
            {
                ((TextBox)sender).BackColor = SystemColors.Highlight;
                ((TextBox)sender).ForeColor = SystemColors.HighlightText;
            }
            if (((Control)sender) is CheckBox)
            {
                ((CheckBox)sender).BackColor = SystemColors.Highlight;
                ((CheckBox)sender).ForeColor = SystemColors.HighlightText;
            }

            if (tabeIndexEditing)
            {
                FieldConfig config = (FieldConfig)((Control)sender).Tag;
                config.TABINDEX = currentTabIndex;
                currentTabIndex = currentTabIndex + 1;
                if (((Control)sender) is TextBox)
                {
                    ((TextBox)sender).Text = config.FIELD_CN_NAME + "(" + config.TABINDEX + ")";
                }
                if (((Control)sender) is CheckBox)
                {
                    ((CheckBox)sender).Text = config.FIELD_CN_NAME + "(" + config.TABINDEX + ")";
                }
            }
        }
示例#12
0
        public override ValidationResult Validate(object value, int row, FieldConfig config)
        {
            if (value is string str && string.IsNullOrWhiteSpace(str))
            {
                return(ValidationResult.Fail(config, "should not be empty", row));
            }

            return(ValidationResult.Success());
        }
示例#13
0
 public void Update(OpenContentInfo data, FieldConfig config)
 {
     if (null == data)
     {
         throw new ArgumentNullException("data");
     }
     Delete(data);
     Add(data, config);
 }
示例#14
0
        /// <summary>
        /// Adds the given source object to the specified Document.
        /// </summary>
        /// <param name="json"></param>
        /// <param name="doc">
        /// The Document to add the object to.
        /// </param>
        /// <param name="config"></param>
        public void AddJsonToDocument(JToken json, Document doc, FieldConfig config)
        {
            if (json == null || json.IsEmpty())
            {
                return;
            }

            Add(doc, null, json, config);
        }
示例#15
0
        public override ValidationResult Validate(object value, int row, FieldConfig config)
        {
            if (value == null)
            {
                return(ValidationResult.Fail(config, "The field should not be null", row));
            }

            return(ValidationResult.Success(null));
        }
示例#16
0
 public void Update(IIndexableItem data, FieldConfig config)
 {
     if (null == data)
     {
         throw new ArgumentNullException("data");
     }
     Delete(data);
     Add(data, config);
 }
示例#17
0
        /// <summary>
        /// Sets whether the result set should be paginated.
        /// </summary>
        /// <param name="fieldConfig">The field config.</param>
        /// <param name="paginate">Should the result be paginated?</param>
        /// <returns>The <see cref="FieldConfig"/>.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="fieldConfig"/> is <c>null</c>.</exception>
        public static FieldConfig SqlPaginate(this FieldConfig fieldConfig, bool paginate = true)
        {
            if (fieldConfig == null)
            {
                throw new ArgumentNullException(nameof(fieldConfig));
            }

            fieldConfig.WithMetadata("JoinMonster.SqlPaginate", paginate);
            return(fieldConfig);
        }
示例#18
0
        public void SqlWhere_WhenWhereDelegateIsNull_ThrowsException()
        {
            var    fieldConfig = new FieldConfig("name");
            Action action      = () => fieldConfig.SqlWhere(null);

            action.Should()
            .Throw <ArgumentNullException>()
            .Which.ParamName.Should()
            .Be("where");
        }
示例#19
0
        internal PropertyFieldSetup(FieldConfig field) : base(field)
        {
            Property   = field.Property ?? throw new ArgumentNullException(nameof(field.Property));
            EditorType = field.EditorType;

            if (field.Relation != null)
            {
                Relation = ConfigProcessingHelper.ProcessRelation(field.Relation);
            }
        }
示例#20
0
        public static FieldConfig HideAll(this FieldConfig source)
        {
            source.Create  = false;
            source.Edit    = false;
            source.Details = false;
            source.Filter  = false;
            source.List    = false;

            return(source);
        }
示例#21
0
        public FieldConfig NewCustomGame(FieldConfig fieldConfig, int SizeX, int SizeY, int MineCount)
        {
            var fieldConfigCustom = (FieldConfig)fieldConfig.Clone();

            fieldConfigCustom.SizeX      = SizeX;
            fieldConfigCustom.SizeY      = SizeY;
            fieldConfigCustom.MinesCount = MineCount;
            NewGame(fieldConfigCustom);
            return(fieldConfigCustom);
        }
示例#22
0
 public virtual void BuildFieldConfig(FieldConfig fieldConfig)
 {
     // LUCENENET: Simplified logic using TryGetValue
     if ((this.config.TryGetValue(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, out IDictionary <string, DateResolution> dateResMap) &&
          dateResMap.TryGetValue(fieldConfig.Field, out DateResolution dateRes)) ||
         this.config.TryGetValue(ConfigurationKeys.DATE_RESOLUTION, out dateRes))
     {
         fieldConfig.Set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
     }
 }
        public DataSourceBuilder AddField(string name, int index, Type type)
        {
            FieldConfig field = new FieldConfig()
            {
                Name = name, FieldType = type, Index = index
            };

            _element.Fields.Add(field);
            return(this);
        }
示例#24
0
        private void Add(LuceneIndexItem data, LuceneController storeInstance)
        {
            if (null == data)
            {
                throw new ArgumentNullException("data");
            }

            FieldConfig indexJson = FilesRepository.GetIndexConfig(data.PortalId);

            Store.Add(LuceneMappingUtils.CreateLuceneDocument(data, indexJson));
        }
        public DataSourceBuilder AddDateField(string name, string format)
        {
            FieldConfig field = new FieldConfig()
            {
                Name      = name,
                FieldType = typeof(DateTime),
                Format    = format,
            };

            _element.Fields.Add(field);
            return(this);
        }
示例#26
0
        /// <summary>
        /// Returns an implementation of
        /// <see cref="FieldConfig"/> for a specific field name. If the implemented
        /// <see cref="QueryConfigHandler"/> does not know a specific field name, it may
        /// return <c>null</c>, indicating there is no configuration for that
        /// field.
        /// </summary>
        /// <param name="fieldName">the field name</param>
        /// <returns>A <see cref="FieldConfig"/>object containing the field name
        /// configuration or <c>null</c>, if the implemented
        /// <see cref="QueryConfigHandler"/> has no configuration for that field</returns>
        public virtual FieldConfig GetFieldConfig(string fieldName)
        {
            FieldConfig fieldConfig = new FieldConfig(StringUtils.ToString(fieldName));

            foreach (IFieldConfigListener listener in this.listeners)
            {
                listener.BuildFieldConfig(fieldConfig);
            }

            return fieldConfig;

        }
示例#27
0
        public void SqlJoin_WhenFieldResolverIsNotNull_DoesntSetResolver()
        {
            var resolver    = new FuncFieldResolver <string>(_ => "");
            var fieldConfig = new FieldConfig("name")
            {
                Resolver = resolver
            };

            fieldConfig.SqlJoin((join, arguments, context, node) => {});

            fieldConfig.Resolver.Should().Be(resolver);
        }
示例#28
0
        public virtual void BuildFieldConfig(FieldConfig fieldConfig)
        {
            IDictionary <string, float?> fieldBoostMap = this.config.Get(ConfigurationKeys.FIELD_BOOST_MAP);

            if (fieldBoostMap != null)
            {
                if (fieldBoostMap.TryGetValue(fieldConfig.Field, out float?boost) && boost != null)
                {
                    fieldConfig.Set(ConfigurationKeys.BOOST, boost);
                }
            }
        }
示例#29
0
        public void SqlColumn_WhenFieldResolverIsNotNull_DoesntSetResolver()
        {
            var resolver    = new FuncFieldResolver <string>(_ => "");
            var fieldConfig = new FieldConfig("name")
            {
                Resolver = resolver
            };

            fieldConfig.SqlColumn("productName");

            fieldConfig.Resolver.Should().Be(resolver);
        }
        //https://www.cnblogs.com/myzony/p/10897895.html

        /*
         *  FE FE FE FE 68 10 44 33 22 11 00 33 78 81 16 1F 90 00 00 77 66 55 2C 00 77 66 55 2C 31 01 22 11 05 15 20 21 84 08 16
         *  说明如下:
         *      FE FE FE FE >--->协议头(1-4组)。
         *      68 >------------>帧起始符。
         *      10 >------------>仪表类型。
         *      44 33 22 11 00 >>倒序为0011223344(以BCD码形式看待),表示表号。
         *      33 78 >--------->倒序为7833 (以BCD码形式看待),表示厂家代码。
         *      81 >------------>实际为控制码+80,我们可以简单认为只有81正确,非81均为异常,不进行解析。
         *      16 >------------>数据域长度,为十进制22,表示后面有22个有效数据。
         *      1F 90 >--------->数据标识 (固定)。
         *      00 >------------>序列号(固定)。
         *      00 77 66 55 >--->倒序为556677.00 (以BCD码形式看待),表示 累计用量。
         *      2C >------------>立方米,其它单位见附1。
         *      00 77 66 55 >--->倒序为556677.00 (以BCD码形式看待),表示 本月用量。
         *      2C >------------>立方米,其它单位见附1。
         *      31 01 22 11 05 15 20:2015-05-11 22:01:31,表示实时时间。
         *      21 84 >--------->状态,两字节,第1字节定义如下,第2字节由厂家自定义。
         *      68:累加和,68+10+44+33+22+11+00+33+78+81+16+1F+90+00+00+77+66+55+2C+00+77+66+55+2C+31+01+22+11+05+15+20+21+84=08
         *      16;结束符。
         */

        private static UsePackageToolExample GetTool()
        {
            var upte = new UsePackageToolExample();

            //下面是比较复杂的情况。在可能的出现的情况下最完整的协议。
            upte.FieldConfig = new FieldConfig(
                new byte[] { 0xFE, 0xEE, 0xFE, 0xEE, 0x68 }, //起始符
                new byte[] { 0x16 },                         //结尾符
                CRCProviderMode.CRC32,
                Endianness.BigEndian,
                1024 * 8,
                (0, 5),  //起始符
                (5, 1),  //属性
                (6, 7),  //地址
                (13, 1), //命令字
                (14, 1), //数据长度
                1,       //CRC
                1        //结尾符//CRC
                );
            return(upte);
        }
示例#31
0
 public Field(FieldConfig fieldConfig)
 {
     SizeX        = fieldConfig.SizeX;
     SizeY        = fieldConfig.SizeY;
     MinesCount   = fieldConfig.MinesCount;
     _fieldConfig = fieldConfig;
     if (_fieldConfig.IsReadyToGame())
     {
         _field = new MineButton[SizeX, SizeY];
     }
     MinesStateChanged += (e, a) => { _fieldConfig.VictoryManager.Check(); };
 }
        public virtual void BuildFieldConfig(FieldConfig fieldConfig)
        {
            IDictionary<string, NumericConfig> numericConfigMap = config
                .Get(ConfigurationKeys.NUMERIC_CONFIG_MAP);

            if (numericConfigMap != null)
            {
                NumericConfig numericConfig;
                if (numericConfigMap.TryGetValue(fieldConfig.Field, out numericConfig) && numericConfig != null)
                {
                    fieldConfig.Set(ConfigurationKeys.NUMERIC_CONFIG, numericConfig);
                }
            }
        }
示例#33
0
        static void OnReady()
        {
            var fields = new JsObject<FieldConfig>();
            fields["OrderID"] = new FieldConfig { type = "number" };
            fields["ShipCountry"] = new FieldConfig { type = "string" };
            fields["ShipName"] = new FieldConfig { type = "string" };
            fields["ShipAddress"] = new FieldConfig { type = "string" };

            new jQuery("#grid").kendoGrid(new GridConfiguration
            {
                dataSourceObject = new DataSourceConfiguration
                {
                    type = "odata",
                    transport = new DataSourceTransportConfiguration
                    {
                        readString = "http://demos.kendoui.com/service/Northwind.svc/Orders"
                    },
                    schema = new DataSourceSchemaConfiguration
                    {
                        model = new ModelObjectOptions
                        {
                            fields = fields
                        }
                    },
                    pageSize = 10,
                    serverPaging = true,
                    serverFiltering = true,
                    serverSorting = true
                },
                height = 250,
                sortableBoolean = true,
                filterable = true,
                columnMenu = true,
                pageableBoolean = true,

                columns = new JsArray<GridColumnConfiguration> 
                { 
                    new GridColumnConfiguration{ field = "OrderID" },
                    new GridColumnConfiguration{ field = "ShipCountry" },
                    new GridColumnConfiguration{ field = "ShipName" },
                    new GridColumnConfiguration 
                    {
                        field = "ShipAddress",
                        filterable = false
                    }
                }

            });
        }
        public virtual void BuildFieldConfig(FieldConfig fieldConfig)
        {
            DateTools.Resolution? dateRes = null;
            IDictionary<string, DateTools.Resolution?> dateResMap = this.config.Get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

            if (dateResMap != null)
            {
                dateResMap.TryGetValue(fieldConfig.Field, out dateRes);
            }

            if (dateRes == null)
            {
                dateRes = this.config.Get(ConfigurationKeys.DATE_RESOLUTION);
            }

            if (dateRes != null)
            {
                fieldConfig.Set(ConfigurationKeys.DATE_RESOLUTION, dateRes.Value);
            }
        }
示例#35
0
 static void OnReady()
 {
     var fields = new JsObject<FieldConfig>();
     fields["FirstName"] = new FieldConfig { type = "string" };
     fields["LastName"] = new FieldConfig { type = "string" };
     fields["City"] = new FieldConfig { type = "string" };
     fields["Title"] = new FieldConfig { type = "string" };
     fields["BirthDate"] = new FieldConfig { type = "date" };
     fields["Age"] = new FieldConfig { type = "number" };
     new jQuery("#grid").kendoGrid(new GridConfiguration
     {
         dataSourceObject = new DataSourceConfiguration
         {
             data = People.createRandomData(50),
             schema = new DataSourceSchemaConfiguration
             {
                 model = new ModelObjectOptions
                 {
                     fields = fields,
                 }
             },
             pageSize = 10
         },
         height = 250,
         scrollable = true,
         sortableBoolean = true,
         filterable = true,
         pageableBoolean = true,
         columns = new JsArray<GridColumnConfiguration> {
            new GridColumnConfiguration { field = "FirstName", title = "First Name", widthNumber = 100},
            new GridColumnConfiguration { field = "LastName", title = "LastName", widthNumber = 100},
            new GridColumnConfiguration { field = "City", widthNumber = 100},
            new GridColumnConfiguration { field = "Title"},
            new GridColumnConfiguration { field = "BirthDate", title = "Birth Date", template = "#= kendo.toString(BirthDate,'MM/dd/yyyy') #"},
            new GridColumnConfiguration { field = " Age", widthNumber = 50 }
        }
     });
 }
示例#36
0
        static void OnReady()
        {
            var fields = new JsObject<FieldConfig>();
            fields["ProductID"] = new FieldConfig { editable = false, nullable = true };
            fields["ProductName"] = "ProductName".As<FieldConfig>();
            fields["UnitPrice"] = new FieldConfig { type = "number" };
            fields["Discontinued"] = new FieldConfig { type = "boolean" };
            fields["UnitsInStock"] = new FieldConfig { type = "number" };
            var crudServiceBaseUrl = "http://demos.kendoui.com/service";
            var dataSource = new DataSource(new DataSourceConfiguration
            {
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        url = crudServiceBaseUrl + "/Products/Update",
                        dataType = "jsonp"
                    },
                    update = new DataSourceTransportUpdateConfiguration
                    {
                        url = crudServiceBaseUrl + "/Products/Update",
                        dataType = "jsonp"
                    },
                    destroy = new DataSourceTransportDestroyConfiguration
                    {
                        url = crudServiceBaseUrl + "/Products/Destroy",
                        dataType = "jsonp"
                    },
                    create = new DataSourceTransportCreateConfiguration
                    {
                        url = crudServiceBaseUrl + "/Products/Create",
                        data = "jsonp"
                    },

                    parameterMap = (options, operation) =>
                        {
                            if (operation.ExactNotEquals("read") && options.As<JsObject>()["models"].As<bool>())
                            {
                                //TODO: return {models: kendo.stringify(options.models)};
                                JsContext.JsCode("return {models: kendo.stringify(options.models)};");
                                return null;
                            }
                            return null;
                        }
                },
                batch = true,
                pageSize = 4,
                schema = new DataSourceSchemaConfiguration
                {
                    model = new ModelObjectOptions
                    {
                        id = "ProductID",
                        fields = fields
                    }
                }
            });
            new jQuery("#pager").kendoPager(new PagerConfiguration
            {
                dataSource = dataSource
            });
            var listView = new jQuery("#listView").kendoListView(new ListViewConfiguration
            {
                dataSource = dataSource,
                template = Kendo.template(new jQuery("#template").html()),
                editTemplate = Kendo.template(new jQuery("#editTemplate").html()),
            }).data("kendoListView").As<ListView>();
            new jQuery(".k-add-button").click(e =>
            {
                listView.add();
                e.preventDefault();
            });
        }
示例#37
0
        static void OnReady()
        {
            var products = new JsArray<Product>
            {
                new Product {
                    ProductID = 1,
                    ProductName = "Chai",
                    Category = "Beverages",
                    UnitPrice = "18:00"
                }, 
                new Product {
                    ProductID = 2,
                    ProductName = "Chang",
                    Category = "Beverages",
                    UnitPrice = "19.00"
                }, 
                new Product {
                    ProductID = 3,
                    ProductName = "Aniseed Syrup",
                    Category = "Condiments",
                    UnitPrice = "10.00"
                }, 
                new Product{
                    ProductID = 4,
                    ProductName = "Chef Anton's Cajun Seasoning",
                    Category = "Condiments",
                    UnitPrice = "22.00"
                },
                new Product{
                    ProductID = 5,
                    ProductName = "Chef Anton's Gumbo Mix",
                    Category = "Condiments",
                    UnitPrice = "21.35"
                }, 
                new Product {
                    ProductID = 6,
                    ProductName = "Grandma's Boysenberry Spread",
                    Category = "Condiments",
                    UnitPrice = "25.00"            
                }
            };


            var fields = new JsObject<FieldConfig>();
            fields["ProductID"] = new FieldConfig { editable = false, nullable = true };
            fields["ProductName"] = new FieldConfig { validation = new ValidatorConfiguration { required = true } };
            fields["Category"] = "Category".As<FieldConfig>();
            fields["UnitPrice"] = new FieldConfig { type = "number", validation = new ValidatorConfiguration { required = true, min = 1 } };


            var dataSource = new DataSource(new DataSourceConfiguration
            {
                pageSize = 30,
                data = products,
                autoSync = true,
                schema = new DataSourceSchemaConfiguration
                {
                    model = new ModelObjectOptions
                    {
                        id = "productID",
                        fields = fields,
                    }
                }
            });
            new jQuery("#grid").kendoGrid(new GridConfiguration
            {
                dataSourceObject = dataSource,
                pageableBoolean = true,
                height = 260,
                toolbar = new GridSortableToolbarConfiguration { text = "create" },
                columns = new JsArray<GridColumnConfiguration> {
                    new GridColumnConfiguration { field = "ProductName", title = "Product Name" },
                   new GridColumnConfiguration { field = "Category", width = "150px", editor = categoryDropDownEditor },
                   new GridColumnConfiguration {  field = "UnitPrice", title = "Unit Price", format = "{0:c}", width = "150px" },
                   new GridColumnConfiguration { commandString = "destroy", title = " ", width = "110px" }
                },
                editableBoolean = true
            });
        }
示例#38
0
        static void OnReady()
        {
            var crudServiceBaseUrl = "http://demos.kendoui.com/service";
            var fields = new JsObject<FieldConfig>();
            fields["ProductID"] = new FieldConfig { editable = false, nullable = true };
            fields["ProductName"] = new FieldConfig { validation = new ValidatorConfiguration { required = true } };
            fields["UnitPrice"] = new FieldConfig { type = "number", validation = new ValidatorConfiguration { required = true, min = 1} }; 
            fields["Discontinued"] = new FieldConfig { type = "boolean" };
            fields["UnitsInStock"] = new FieldConfig { type = "number", validation = new ValidatorConfiguration { required = true, min = 1} };

            var dataSource = new DataSource(new DataSourceConfiguration
            {
                transport = new DataSourceTransportConfiguration
                {
                    read = new DataSourceTransportReadConfiguration
                    {
                        url = crudServiceBaseUrl + "/Products/Update",
                        dataType = "jsonp"
                    },
                    destroy = new DataSourceTransportDestroyConfiguration
                    {
                        url = crudServiceBaseUrl + "/Products/Destroy",
                        dataType = "jsonp"
                    },
                    parameterMap = (options, operations) =>
                         {
                             var models = options.As<JsObject>()["models"];
                             if (operations.ExactNotEquals("read") && models.As<bool>())
                             {
                                 //TODO : find return new stringify {models= Kendo.stringify(models)};
                                 return null;
                             }
                             return null;
                         }

                },
                batch = true,
                pageSize = 30,
                schema = new DataSourceSchemaConfiguration
                {
                    model = new ModelObjectOptions
                    {
                        id = "ProductID",
                        fields = fields,
                    }
                }
            });

            new jQuery("#grid").kendoGrid(new GridConfiguration
            {
                dataSourceObject = dataSource,
                pageableBoolean = true,
                height = 400,
                toolbar = new GridSortableToolbarConfiguration { text = "create" },
                columns = new JsArray<GridColumnConfiguration> {
                    new GridColumnConfiguration { field ="ProductName", title = "Product Name" },
                    new GridColumnConfiguration{ field = "UnitPrice", title ="Unit Price", format = "{0 =c}", width = "150px" },
                    new GridColumnConfiguration{ field = "UnitsInStock", title ="Units In Stock", width = "150px" },
                    new GridColumnConfiguration{ field = "Discontinued", width = "100px" },
                    //TODO:  enum    { command: ["edit", "destroy"], title: "&nbsp;", width: "210px" }],
                    new GridColumnConfiguration{ commandStringArray = new JsArray<JsString> {"create", "destroy"}, title = "&nbsp;", width = "210px" }
                },
                editableString = "popup",
            });
        }
示例#39
0
 public Field(FieldConfig config) { throw new Exception(); }