How to send parameters with listview request?

7 posts, 0 answers
  1. Parthasarathi
    Parthasarathi avatar
    24 posts
    Member since:
    Oct 2012

    Posted 01 Mar 2013 Link to this post

    Hi All,

    I am trying to pass parameters to controller action method from listview. But mvc controller action is not firing.. Script is below.
       
        <script type="text/x-kendo-tmpl" id="titletemplate">
                    <div class="titleClass">
                    <input type='checkbox' class='titleCheck' id=${CplGuid}  value=${aaaa}" > ${bbbb} </div>            
                    </script>
                    @(Html.Kendo().ListView<Dcip.KeyVault.Portal.Areas.KeyVaultUI.Models.DownloadKdmPE>()
            .Name("titles")
                            //.Events(events => events.DataBound("OnKeyDataBound"))
            .TagName("div")
            .ClientTemplateId("titletemplate")
            .DataSource(source =>
            source.Read(
            read => read.Action("xxxx", "yyyy").Data("filterTitles"))
            .PageSize(25)
            )       
            .Selectable(selection =>
            {
                selection.Enabled(true);
                selection.Mode(ListViewSelectionMode.Multiple);
            })
                            //.Pageable(pager => { pager.PageSizes(true); pager.ButtonCount(1); })
            .Pageable(pager => { pager.PageSizes(new int[] { 10, 20, 25 }); pager.ButtonCount(1); })
            )

    <script type="text/javascript">
     function filterTitles() {
            alert('Hi Titles');
            return { xxId: 1 ,yyId:1 };
        }
    </script>


    Immediate help would be appreciated.

    Regards,
    Partha.
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 05 Mar 2013 Link to this post

    Hello Partha,

    Your code looks completely valid and the ListView should perform request to fetch the data from the action method which you specified. Are there any JavaScript errors in the console?

    If there are not, could you put this into a small project so we can see what goes wrong?

    Kind regards,
    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. Kendo UI is VS 2017 Ready
  4. David
    David avatar
    8 posts
    Member since:
    Jun 2012

    Posted 25 Apr 2013 Link to this post

    Any update on this?  I am having the exact same issue.  I know the javascript method for the data parameters fires, because I have an alert as well.  However, the controller is never hit.  If I remove the .Data(...) part, the controller is hit and returns data.
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 29 Apr 2013 Link to this post

    Hello,

    Please check the response from the server. There is probably an exception thrown and the response message should indicate what is causing the problem.

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. David
    David avatar
    8 posts
    Member since:
    Jun 2012

    Posted 29 Apr 2013 Link to this post

    There is no response from the server, because the method to retrieve the data is never being called when I have .Data(...) on the Action.
  7. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 29 Apr 2013 Link to this post

    Hello David,

    I am not sure what is causing the problem in this case. Are there any JavaScript errors? If there are not any errors, could you check the attached sample project and let me know if I am missing something?

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. David
    David avatar
    8 posts
    Member since:
    Jun 2012

    Posted 29 Apr 2013 Link to this post

    So, my issue turns out that my controller method's additional parameter was named "filter".  This is apparently the problem due to the Kendo object using a property of that name.  Changing my parameter name fixed it.  Thank you for the sample. It helped.
Back to Top
Kendo UI is VS 2017 Ready