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

Partial view datasource url for different areas not working as expected

1 Answer 301 Views
View
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 20 Jun 2014, 03:52 AM

Scenario:

I have a kendo ui panel bar in a view within an area(say MyArea) which has kendoComboBox (partial view) from a different area(say Services)

@(Html.Kendo().PanelBar()
        .Name("PanelBar")
        .Items(search =>
            {
                search.Add()
                    .Text("Search YLAU EdiLog")
                    .Expanded(true)
                    .Content(@<text>
                                <form method="post" id="myForm">
                                          <div class="TableCell">@Html.Partial("~/Services/Views/Customer/WMSCustomerList.cshtml")  </div>

     
WMSCustomerList.cshtml(partial view):

<script type="text/javascript">

    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url:"Services/Customer/WMSCustomerList",
                dataType: "json"                  
            }
        }
    });
    $("#Company").kendoComboBox({
        dataSource: dataSource,
        dataTextField: "AccountName",
        dataValueField:"AccountCode"
    })

Issues:

- The url specified for the kendo combo box does not gets called i.e, the controller from a different area(Services) does not get called. 

Q: How do you call a datasource from different areas in a partial view ?


- I changes the datasource url by adding a slash in the start of the url (url:"/Services/Customer/WMSCustomerList",) which then works correctly. 

Q: What is the significance of adding a slash in front of the url? Why doesn't the url area switching work without a slash? Please clarify

Thanks!



    



1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 24 Jun 2014, 06:03 AM
Hi Sam, 

The slash signifies whether the URL should link to the root path, or to the current one. For example: 
<a href="/test">Test link</a> ===>  localhost/test
<a href="test" >Test link</a> ===>  localhost/Area/Controller/test
It is generally recommended to use the Url helper instead of hard-coded links. For example: 
Url.Action("View", "Controller", new { area="areaName" })

Regards,
Alexander Popov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
View
Asked by
Sam
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or