pass parameter or model for ListView to partialView in listView with use ClientTemplateId

1 Answer 725 Views
Grid ListView
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
Mohamad Javad asked on 13 Feb 2023, 02:38 PM

hi

i need to pass parameter or model for ListView (not Model Page) to partialView  Page in listView with use ClientTemplateId

my code is:

<script type="text/x-kendo-tmpl" id="template">
    @Html.Partial("_myPartialView",new MSG_UserMessagesList_Ex_For_Model  { Name =  #: FileName # });
</script>
@(Html.Kendo().ListView<MSG_UserMessagesList_Ex_For_Model>()
                                        .Name("listView")
                                        .TagName("div")
                                        .HtmlAttributes(new { style = "height:100%; width: 100%;" })
                                        .ClientTemplateId("template")
                                        .DataSource(dataSource => dataSource
                                        .Ajax()
                                        .Read(r => r.Url(@Url.Page("MsgList", "MSG_UserMessagesList_Ex")).Data("forgeryToken"))
                                        )
                                        )
plase Help Me

1 Answer, 1 is accepted

Sort by
0
Accepted
Mihaela
Telerik team
answered on 16 Feb 2023, 09:51 AM

Hi Mohamad,

Thank you for the shared code snippet.

You are on the right track to pass a Model property to the partial View. If you wrap the "FileName" in quotes, it should be passed correctly:

<script type="text/x-kendo-tmpl" id="template">
    @Html.Partial("_myPartialView",new MSG_UserMessagesList_Ex_For_Model  { Name =  "#: FileName #" });
</script>

@(Html.Kendo().ListView<MSG_UserMessagesList_Ex_For_Model>()
  .Name("listView")
  .TagName("div")
  .HtmlAttributes(new { style = "height:100%; width: 100%;" })
  .ClientTemplateId("template")
  ...
)

//_myPartialView.cshtml
@{
    Layout = null;
}

@model ProjectName.Data.MSG_UserMessagesList_Ex_For_Model

@Model.Name

I hope that helps.

 

 

Regards, Mihaela Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
commented on 27 Feb 2023, 11:59 AM

Hello
Thank you for your answer.
I have another problem too. Fileid in "#=FileId#" is not passed. Where is the problem


           <script type="text/x-kendo-tmpl" id="templateFileUpload"><form dir="rtl" method="post">
                                            <button type="submit" class="btn btn-link"
 formaction="@Url.Page("/Ticket/MsgList", "DownloadFile", new { FileId = "#=FileId#"})" >
                                          download file
                                            </div>
                                        </button>
                                    </form>
                                    </script>

Mihaela
Telerik team
commented on 28 Feb 2023, 12:34 PM

Hi Mohamad,

You could pass the "FileId" as per the example below:

<script type="text/x-kendo-tmpl" id="templateFileUpload">
  <form dir="rtl" method="post">
    <button type="submit" class="btn btn-link" formaction="@Url.Page("pageName", "pageHandler")?FileId=#=FileId#" >
         download file
    </button>
  </form>
 </script>

 

Also, you can use @Url.Action():

formaction='@Url.Action("MsgList","DownloadFile")?FileId=#=FileId#'

 

Tags
Grid ListView
Asked by
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Mihaela
Telerik team
Share this question
or