We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How can I do a Custom Filter with column is Enum value?

Thread ID:

Created:

Updated:

Platform:

Replies:

119569 Jul 9,2015 10:31 AM Jul 10,2015 06:57 AM ASP.NET MVC 1
loading
Tags: Grid
Cristiano Souza Silva
Asked On July 9, 2015 10:31 AM

Hello,

I'm using MVC 5 + Knockoutjs.
I've a table named by ProductCategories, this one has a column named by Type (Int16). My enum define the value that column.

Now I need to create a custom column and it is necessary has a filter column, but I don't know how can I do that, because the information that show is a String (data annotation from enum) and my database has a Int16 column.

I tried to do, but doesn't work. When I perform a filter happen an exception.

Error:
{"Identifier 'TypeName' is not a parameter or variable or field of 'Sight.NoAlvo.TO.Entity.BasicForm.ProductCategory.ProductCategory'. If 'TypeName' is a property please add the FieldAlias or Storage attribute to it or declare it as a field's alias."}

My solution:

Entity
public class ProductCategory : BaseEntity
 {
        #region .: Properties :.
        [DataMember]
        public Int64 Id { get; set; }
        [DataMember]
        public String Name { get; set; }
        [DataMember]
        public Double MinimalValue { get; set; }
        [DataMember]
        public Int16 Type { get; set; }
        [IgnoreDataMember]
        public String TypeName { get
            {
                return ((EnumCategoryType)this.Type).GetNameIdentifier();
            }
        }
}

Controller

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult KODataSource(DataManager clsDataManager)
        {
            BaseResult<ProductCategory> clsData = ProductCategoryBusiness.GetAll(clsDataManager);

            ResultModel result = new ResultModel();

            result.result = clsData.Result;
            result.count = clsData.Count;

            return Json(result, JsonRequestBehavior.AllowGet);
        }

View 
$(function () {
            window.baseView = {
                dataSource: ej.DataManager({ url: '@Url.Action("KODataSource")', adaptor: "UrlAdaptor" }),
                column: [
                          { headerText: "Ações", template: true, templateID: '#CustomCommand', width: '10%' },
                          { field: "Name", headerText: "Nome" },
                          { field: "MinimalValue", headerText: "Valor mínimo", format: "R$ {0:n}" },
                          { field: "TypeName", headerText: "Tipo de Categoria" }, ]
            };
            ko.applyBindings(baseView);
        });


Thank you.

Attachment: error_3dd33906.zip

Ragavee U S [Syncfusion]
Replied On July 10, 2015 06:57 AM

Hi Cristiano,

We have analyzed the reported issue and also the screenshot that you have shared with us.

Based on the provided information, we have created a sample and we are sorry to let you know that we are unable to reproduce the issue mentioned at our end. The sample can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/119569/ze/KoSample-635414846

Please try the sample and if you still face any difficulties, please get back to us with the below details.

1.       Screenshot of the exception
2.       Call Stack of the exception obtained
3.       Please reproduce the issue in the above provided sample.

Note: We suspect that you have shared the incorrect screenshot corresponding to the exception obtained. So please share the correct screenshot with us which will be very helpful for us to assist you accordingly.

Please get back to us if you need any further assistance.

Regards
Ragavee U S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;