This is a migrated thread and some comments may be shown as answers.

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

7 Answers 209 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 2
Scott asked on 18 Jun 2012, 09:47 PM
How do I configure a parameterMap in the MVC version of this Kendo UI control?

7 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 19 Jun 2012, 11:21 AM
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!
0
Guilherme
Top achievements
Rank 1
answered on 22 Feb 2013, 05:52 PM
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!
0
Georgi Krustev
Telerik team
answered on 26 Feb 2013, 12:16 PM
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!
0
Guilherme
Top achievements
Rank 1
answered on 26 Feb 2013, 10:53 PM
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!
0
Georgi Krustev
Telerik team
answered on 01 Mar 2013, 02:09 PM
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!
0
Guilherme
Top achievements
Rank 1
answered on 01 Mar 2013, 02:43 PM
Hey!!!

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

Do we have any other option?

Regards
0
Georgi Krustev
Telerik team
answered on 01 Mar 2013, 03:25 PM
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!
Tags
AutoComplete
Asked by
Scott
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Guilherme
Top achievements
Rank 1
Share this question
or