MVC Model Binding with Filters

2 posts, 0 answers
  1. Evan
    Evan avatar
    14 posts
    Member since:
    Oct 2012

    Posted 28 Jan 2013 Link to this post

    I have some comboboxes that cascade from one to the other.  I would also like to be able to filter based on partial text entered into the combobox.  This isn't working out of the box, so I'm working on coding it server-side.  It appears that the text is being posted to the servers, but I can't find a server-side object to bind to the post.  Here's what's being posted.  In my case "Value" is the value of the parent combobox this combobox is cascading from.

    1. filter[logic]:
      and
    2. filter[filters][0][field]:
      Value
    3. filter[filters][0][operator]:
      eq
    4. filter[filters][0][value]:
      2
    5. filter[filters][1][value]:
      purity
    6. filter[filters][1][field]:
      Text
    7. filter[filters][1][operator]:
      contains
    8. filter[filters][1][ignoreCase]:
      true

    I took a look at IFilterDescriptor, FilterDescriptor, and CompositeFilterDescriptor.  They seem to have similar fields to those shown above, but they aren't binding when I try to use them as input to my Action method.  I haven't had any luck finding a similar thread or any documentation around this.

    Again, my end goal is to have cascading comboboxes without losing the ability to filter by text entered, so if there's any advise there, I'm all ears.  Also, any advice on how to bind the posted filter info is welcome.
    Thanks,
    --Evan


    Also, here's the definition of my comboboxes as a side note:
    <tr>
                <td class="formTableLabel">Price Publisher: </td>
                <td>
                    @(Html.Kendo().ComboBox()
                        .Name("PricePublisherId")
                        .DataValueField("Value")
                        .DataTextField("Text")
                        .BindTo(Model.ReferenceData.PricePublisherList)
                        .Filter(FilterType.Contains)
                        .HtmlAttributes(new { required = "required", validationMessage = "Please select an option." }))
                </td>
            </tr>
            <tr>
                <td class="formTableLabel">Price Instrument: </td>
                <td>
                    @(Html.Kendo().ComboBox()
                        .Name("PriceInstrumentId")
                        .DataValueField("Value")
                        .DataTextField("Text")
                        .Placeholder("(Empty)")
                        .DataSource(source =>
                        {
                            source.Read(read =>
                            {
                                read.Action("GetPriceInstrumentList", "TradeEntry").Data("priceInstrumentListJSON").Type(HttpVerbs.Post);
                            })
                            .ServerFiltering(true);
                        })
                        .Enable(false)
                        .AutoBind(false)
                        .CascadeFrom("PricePublisherId")
                        .Filter(FilterType.Contains)
                        .HtmlAttributes(new { required = "required", validationMessage = "Please select an option." }))
                </td>
            </tr>
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 30 Jan 2013 Link to this post

    Hello Evan,

    I already posted an answer in the support ticket you opened. For reference I will paste the answer here. Feel free to continue our conversation here or in the support ticket.

    ****************************************************************************************************************

    What exactly did you try to handle the server side filtering, could you share some code? 

    Basically server filtering with cascading ComboBoxes is covered in this demo. Also you can send the values in your own format like covered in this part of the documentation. Or you can use the change event and perform dataSource.read for the child combo manually.

    ****************************************************************************************************************

    Greetings,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top