0

我在 mvc3 中使用 Telerik 面板栏,并且在传递 Url 时遇到问题??任何人都可以帮助我如何在我看来通过 Url。

4

2 回答 2

1

您需要在模型中动态引入控制器/操作名称并创建并传递 url

.Items(sub =>
              {
              for (int i = 0; i < Model.Count(); i++)
                 {

                  sub.Add().Text(Model.ElementAt(i).DisplayText)
                   .Url(Url.Action(Model.ElementAt(i).ActionName, Model.ElementAt(i).ControllerName, new { id = Model.ElementAt(i).IDParam }))

              }});
于 2012-07-03T12:53:26.153 回答
0

If I understand your question correctly, I did something similiar to this using the PanelBar and Grid.In the panel bar, put a js function in the OnSelect event:

Html.Telerik().PanelBar()
   .Name("PanelBar")
      .ClientEvents(events =>
      {
         events.OnSelect("getEvent");
      })
      .Items(panelbar =>
      {
         panelbar.Add()
            .Text("Header Text")
            .Expanded(true)
            .Items(item =>
            {
               item.Add()
                   .Text("Test1");
               item.Add()
                   .Text("Test2");
            });
     }).Render();

In the getEvent function, assign a variable to each item and make an ajax post to an actionresult on your controller or something. In my case I just made the grid rebind.

function getEvent(e) {
        panelItem = $(e.item).text();
        if (panelItem == "Test1") {
            var eventid1 = 1;
        }
        if (panelItem == "Test2") {
            var eventid2 = 2;
        }
        //make ajax post here or something
        $('#TheGrid').data('tGrid').rebind();
        //            $.ajax({
        //                url: '/Controller/Action',
        //                type: 'POST',
        //                data: {
        //                    eventid1: eventid1,
        //                    eventid2: eventid2,
        //                    panelItem: panelItem
        //                }
        //            });
}

and in your controller make a conditional statement for the eventids and perform the action you want. Hope this helps.

于 2012-07-03T19:03:38.323 回答