简体   繁体   English

在 mvc3 razor 客户端上显示来自 wcf 服务的数据

[英]display data from wcf service on mvc3 razor client

I have a client asp.net mvc3 razoc which consumes a wcf service.我有一个使用 wcf 服务的客户端 asp.net mvc3 razoc。 I have a method GetTopCollections which return Collection[] "Top collections on the server" and I have a method GetTreeView(string id) which return only the first level of this Collection not all the tree.我有一个方法 GetTopCollections 返回 Collection[]“服务器上的顶级集合”,我有一个方法 GetTreeView(string id) 只返回这个集合的第一级而不是所有的树。

I want, on the first time to display top collections(It's done), And when I click on the one of those top collections, I display the first level of it's tree by calling the method GetTreeView(handle).我想在第一次显示顶级集合时(已完成),当我单击这些顶级集合中的一个时,我通过调用方法 GetTreeView(handle) 显示其树的第一级。

This is the first method on the controller:这是控制器上的第一个方法:

public ActionResult GetData()
    {
        client = new DSServiceClient();
        Collection[] _top = new Collection[10];
        client.Open();
        _top = client.GetTopCollections();
        client.Close();
        return View(_top);
    }

this is the view of GetData这是 GetData 的视图

@model DSClient.Controllers.Collection[]

@{
   ViewBag.Title = "GetData";
   @Html.ActionLink( @Model.ElementAt(0).Handle,"GetData3","Home",new { handle=@Model.ElementAt(0).Handle });
 }

this is GetData2()这是 GetData2()

public PartialViewResult GetData2(string handle)
    {
        client = new DSServiceClient();
        Tree tree = new Tree();
        tree = client.GetTreeView(handle);
        return PartialView("~/Views/Shared/GetData2.cshtml",tree);
    }

And this is the view of GetData2这是 GetData2 的视图

@model DSClient.Controllers.Tree

@{
ViewBag.Title = "GetData3";
@Model.listObjects.ElementAt(0).Name;
}

And this is the link to call the GetData这是调用 GetData 的链接

@Html.ActionLink("WebService", "GetData", "Home")

My problem is that the result of GetData3 is displayed on on other view, but I want to display that on the same view.Like a Tree View.我的问题是 GetData3 的结果显示在其他视图上,但我想在同一个视图上显示它。就像树视图一样。 Can some one help me please?有人能帮助我吗?

You will need to either:您需要:

  1. Render the whole tree and hide the second level until the user clicks it渲染整个树并隐藏第二层直到用户点击它
  2. Load only the first level like you are doing and use AJAX to load the others as the user clicks them像您一样只加载第一级,并在用户单击时使用 AJAX 加载其他级别

Some jQuery tree views for you -> http://freebiesdesign.com/7-best-jquery-treeview-plugins/一些 jQuery 树视图 -> http://freebiesdesign.com/7-best-jquery-treeview-plugins/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM