MVC3 - What should the controller action method parameters look like??

8 posts, 1 answers
  1. Scott
    Scott avatar
    68 posts
    Member since:
    Nov 2011

    Posted 18 Jun 2012 Link to this post

    How do I configure a parameterMap in the MVC version of this Kendo UI control?
  2. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 19 Jun 2012 Link to this post

    Hello Scott,

    Currently, the DataSource builder used by the AutoComplete does not provide the ability to override the parameterMap. Nevertheless, you can send additional parameters to the server using Data method of the DataSource builder:

    ...
    .DataSource(source => {
                  source.Read(read =>
                  {
                      read.Action("GetProducts", "Home")
                          .Data("onAdditionalData");
                  })
    )
    <script>
        function onAdditionalData() {
            return {
                filterText: $("#products").val()
            };
        }
    </script>
    Check the "serverfiltering.cshtml" demo.

    Regards,
    Georgi Krustev
    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
  4. Guilherme
    Guilherme avatar
    23 posts
    Member since:
    Nov 2010

    Posted 22 Feb 2013 Link to this post

    Hello

    I tried to use the default parameterMap, but doesn't work for me.
    @(Html.Kendo().AutoComplete()
                        .Name("PartSearchCriteria")
                        .DataSource(dataSource => dataSource
                            .Read(conf => conf.Action("FindPart_SelectPart", "Order").Type(HttpVerbs.Post)
                                    .Data("editOrderView.PartSearchCriteria_Data"))
                            .ServerFiltering(false)
                        )
                        .Filter(FilterType.Contains)
                        .HighlightFirst(true)
                        .Suggest(true)
                        .HtmlAttributes(new { title = UI_Resources.FindParts_PartSearchCriteriaTooltip, style = "width:300px;"})
                    )
    Doesn't matter what I do, I'll never receive the parameter which represents the input data from user.
    The only way which I found is overriding the paramerterMap as you said.
    My question is: how can I use the default parameterMap without using ServerFiltering(true)?

    Thanks!
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 26 Feb 2013 Link to this post

    Hello ,

     
    The Data callback should sufficient to sent any additional parameters to the server. Could you share with us what is the PartSearchCriteria_Data implementation? Any runnable test project, which replicates the problem will be of a great help.

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Guilherme
    Guilherme avatar
    23 posts
    Member since:
    Nov 2010

    Posted 26 Feb 2013 Link to this post

    Hello Again

    The point is: I dont wanna any additional parameters, I just want the default one (input from user).

    AutoComplete:
    @(Html.Kendo().AutoComplete()
                        .Name("PartSearchCriteria")
                        .DataSource(dataSource => dataSource
                            .Read(conf => conf.Action("FindPart_SelectPart", "Order").Type(HttpVerbs.Post)
                                .Data("editOrderView.PartSearchCriteria_Data")
                            )
                            .ServerFiltering(false)
                        )
                        .Filter(FilterType.Contains)
                        .HighlightFirst(true)
                        .Suggest(true)
                        .HtmlAttributes(new { title = UI_Resources.FindParts_PartSearchCriteriaTooltip, style = "width:300px;"})
                    )
    PartSearchCriteria_Data:
    PartSearchCriteria_Data: function (e) {
                    return {
                        text: $("#PartSearchCriteria").val()
                    };
                },
    Controller:
    [HttpPost]
    public ActionResult FindPart_SelectPart(string text)
    { ... }

    The only way that I manage to receive the "string text" parameter is using .Data("editOrderView.PartSearchCriteria_Data")
    I checked the HTTP POST with Bugzilla and for sure no http parameter are passing to server.

    Do exist a way to receive the default parameter in the server without using this custom event?

    Thanks!
  7. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 01 Mar 2013 Link to this post

    Hello Guilherme,

     
    In that case you can get the filter value in the Action method like this:

    Request.QueryString["filter[filters][0][value]"]
    Please note that index can be different.

    Other option is to parse filter options manually. Check this demo, which shows how to achieve this.

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Guilherme
    Guilherme avatar
    23 posts
    Member since:
    Nov 2010

    Posted 01 Mar 2013 Link to this post

    Hey!!!

    You solution only works with:
    .ServerFiltering(true)
    But I'd like to filter in client side.

    Do we have any other option?

    Regards
  9. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 01 Mar 2013 Link to this post

    Hello Guilherme,

     
    Sorry, I missed the .ServerFiltering(false) in your configuration. Unfortunately in that case you will need to use Data callback.

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