Supplying route values from javascript?

2 posts, 0 answers
  1. Jason
    Jason avatar
    6 posts
    Member since:
    Sep 2012

    Posted 07 Aug 2012 Link to this post

    Hi.  I have an MVC3 application programmed in VB.NET.

    In this MVC3 application, I have a controller.  The controller's JSON action has 3 parameters as specified below:

            Function JSONRetrieveDocuments(
                ByVal contactId As Guid,
                ByVal includeLoanBasedDocuments As Boolean,
                <DataSourceRequest()> request As DataSourceRequestAs ActionResult

    As part of a Grid, I build a route value dictionary as part of the function that creates the CrudOperationBuilder:

            Public Function CreateCrudOperationBuilder(cob As Kendo.Mvc.UI.Fluent.CrudOperationBuilderAs Kendo.Mvc.UI.Fluent.CrudOperationBuilder
                Dim theRouteValueDictionary As New RouteValueDictionary()
     
                theRouteValueDictionary.Add("contactId", Request.QueryString("contactId"))
    	    'theRouteValueDictionary.Add("includeLoanBasedDocuments", ???
    
               Return cob.Action("JSONRetrieveDocuments""ContactBasedDocument", theRouteValueDictionary)         End Function

    When making the call to JSONRetrieveDocuments, I want to be able to populate the includeLoanBasedDocuments parameter of the controller's action by simply returning the checked status of a checkbox...  so I created this javascript function:

        function ShouldIncludeLoanBasedDocuments() {
            return $("#cbIncludeLoanBasedDocuments")[0].checked;
        }


    I'm curious 
    a) how do I supply the result of the javascript function to the route values?
    b) am I following best practices on this one?   It seems like this would be a common operation, but I couldn't find any documentation on it.

    Thanks,

    Jason
  2. Jason
    Jason avatar
    6 posts
    Member since:
    Sep 2012

    Posted 07 Aug 2012 Link to this post

    The solution that I found was to use the Data() function of the CrudOperationBuilder and construct the parameters in javascript instead of .net code.
  3. Kendo UI is VS 2017 Ready
Back to Top