2012-07-05 111 views
0

我的局部视图包含此代码:Telerik的标签栏(按需标签)无法正常工作

@(Html.Telerik().TabStrip() 
     .Name("MeasurementScheme") 
     .Items(tab => 
     { 
      tab.Add() 
       .Text("Weight Measure") 
       .LoadContentFrom("IndexWeight", "MeasurementScheme") 
       .Selected(true); 




      tab.Add() 
       .Text("Dimension Measure") 
       .LoadContentFrom("IndexDimension", "MeasurementScheme"); 




     }) 
     ) 

但是当我运行我的代码只显示第一个选项卡的局部视图,当第二个选项卡上单击它不叫第二个。

还有一想,当我第二个选项卡的.selected属性更改为真,而不是第一不是第二个选项卡工作正常,先不调用它的观点?

确定KK这是我的控制器

using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.Mvc; 
    using CommerceSuite.Services; 
    using CommerceSuite.Web.Models; 
    using CommerceSuite.Data; 
    using System.Web.Mvc.Html; 
    using CommerceSuite.Web.Infrastructure; 
    using CommerceSuite.Web.Models.MeasurementScheme; 
    using Telerik.Web.Mvc; 
    using System.Threading; 
    namespace CommerceSuite.Web.Controllers 
    { 
     public class MeasurementSchemeController : BaseCsController 
{ 
    private readonly IMeasurementSchemeService _measurementSchemeService; 
    public MeasurementSchemeController(IMeasurementSchemeService measurementSchemeService) 
    { 
     this._measurementSchemeService = measurementSchemeService; 
    } 

    public ActionResult Index() 
    { 
     return PartialView("_Index"); 
    } 

    // Default Partial View Page of Measure Dimension 
    public ActionResult IndexDimension() 
    { 
     return PartialView("_IndexDimension"); 
    } 

    // return Json List of All MeasureDimension - Method is Invoked in Index Partival View 
    [GridAction] 
    public ActionResult MeasureDimensionView() 
    { 
     var dimensionCollection= _measurementSchemeService.GetAllMeasurementDimension().Select(x=> 
      new MeasureDimensionModel() 
     { 
      MeasureDimensionId=x.MeasureDimensionId, 
      Name=x.Name, 
      Symbol = x.Symbol, 
      Ratio=x.Ratio.Value, 
      IsActive=x.IsActive 
     }); 
     return Json(dimensionCollection, JsonRequestBehavior.AllowGet); 
    } 

    public ActionResult IndexWeight() 
    { 
     return PartialView("_IndexWeight"); 
    } 

    // return Json List of All MeasureDimension - Method is Invoked in Index Partival View 
    [GridAction] 
    public ActionResult MeasureWeightView() 
    { 
     var weightCollection = _measurementSchemeService.GetAllMeasurementWeight().Select(x => 
      new MeasureWeightModel() 
      { 
       MeasureWeightId = x.MeasureWeightId, 
       Name = x.Name, 
       Symbol = x.Symbol, 
       Ratio = x.Ratio.Value, 
       IsActive = x.IsActive 
      }); 
     return Json(weightCollection, JsonRequestBehavior.AllowGet); 
    } 

,这是我的局部视图_Index.cshtml

 @model CommerceSuite.Web.Models.MeasurementScheme.MeasureWeightModel 

     @{ 
     ViewBag.Title = "Measurement Information"; 
     Layout = "~/Views/Shared/_LayoutPartial.cshtml"; 

     } 

     @Html.Partial("~/Views/Shared/_Notifications.cshtml") 

    <div style="margin-top: 10px; background-color:rgba(18, 149, 223, 0.35); color:#000000; text-align:center; border-bottom-style:dotted; border-top-style:dotted; border-top-width:1px; border-top-color:#aaa; border-bottom-width:1px; border-bottom-color:#aaa;"> 
<h1 style="font-size: 17px; line-height:24px; font-weight:normal;">Measurement Schemes</h1> 

@section LeftOption{ 
<a href="#"><img src="@Url.Content("~/Content/themes/myicons/home.png")" width="28px;" title="Home" alt="Home" /></a> &nbsp;&nbsp;&nbsp; 
<a href="#"><img src="@Url.Content("~/Content/themes/myicons/back.png")" width="28px;" title="Back" alt="Back" /></a> &nbsp;&nbsp;&nbsp; 
<a href="#"><img src="@Url.Content("~/Content/themes/myicons/forward.png")" width="28px;" title="Forward" alt="Forward" /></a> &nbsp;&nbsp;&nbsp; 
<a href="#"><img src="@Url.Content("~/Content/themes/myicons/refresh.png")" width="28px;" title="Refresh List" alt="Refresh" /></a> &nbsp;&nbsp;&nbsp; 
<a href="#"><img src="@Url.Content("~/Content/themes/myicons/search.png")" width="28px;" title="Search" alt="Search" /></a> 
} 
@section RightOption{ 
<a href="#" Onclick="csPopupOpen('Add Measurement Scheme','@Url.Action("Create")')"><img src="@Url.Content("~/Content/themes/myicons/add.png")" width="28px;" title="Add New" alt="Add" /></a> &nbsp;&nbsp;&nbsp; 
<a href="#" Onclick="csPopupOpen('Delete Measurement Scheme','@Url.Action("#")')"><img src="@Url.Content("~/Content/themes/myicons/delete.png")" width="28px;" title="Delete" alt="Delete" /></a> &nbsp;&nbsp;&nbsp; 
<a href="#" Onclick="csPopupOpen('Print Measurement Schemes','@Url.Action("#")')"><img src="@Url.Content("~/Content/themes/myicons/print.png")" width="28px;" title="Print List" alt="Print" /></a> 

}


 @(Html.Telerik().TabStrip() 
     .Name("TabStrip") 
     .Items(tab => 
     { 

      tab.Add() 
       .Text("Dimension Measure") 
       .LoadContentFrom("IndexDimension", "MeasurementScheme") 
       .Selected(true); 


      tab.Add() 
       .Text("Weight Measure") 
       .LoadContentFrom("IndexWeight", "MeasureWeight"); 


     }) 

     ) 

,这是measureweight _IndexDimension

@model CommerceSuite.Web.Models.MeasurementScheme.MeasureDimensionModel 

     @(Html.Telerik().Grid<CommerceSuite.Web.Models.MeasurementScheme.MeasureDimensionModel>() 
        .Name("MeasurementScheme")   
      .DataBinding(databinding => { 
       databinding.Ajax().Select("MeasureDimensionView", "MeasurementScheme"); 
      }) 
      .Columns(columns => 
       { 
        columns.Bound(p=>p.MeasureDimensionId) 
        .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= MeasureDimensionId #>' />") 
        .HeaderTemplate(
        @<text> 
         <input type="checkbox" title="Select/Unselect All Records" id="checkAllRecords" /> 
           </text> 
       ) 
        .Title("") 
        .Width(40) 
        .HtmlAttributes(new { style = "text-align:center" }); 
        columns.Bound(p => p.Name).Width(300); 
        columns.Bound(p => p.Symbol).Width(100); 
        columns.Bound(p => p.Ratio).Width(100); 
        columns.Bound(p => p.IsActive).Width(75); 
        columns.Bound(p => p.IsActive).Title("Update").Sortable(false).Filterable(false).Width(50) 
        .ClientTemplate("<img src='../../Content/themes/myicons/edit.png' title='Edit' width='20' onclick='csPopupOpen(\"HELLO\",\"" + @Url.Action("EditDimension") + "\",<#=MeasureDimensionId #>,\"" + @Url.Action("IndexDimension") + "\")' value='Edit' > <img src='../../Content/themes/myicons/del.ico' width='20' title='delete' name='<#=MeasureDimensionId #>' onclick='csPopupOpen(\"HELLO\",\"" + @Url.Action("Delete") + "\",<#=MeasureDimensionId #>)' value='Delete' > ").Width(50); 
       }) 
      .Pageable() 
      .Scrollable() 
      .Sortable() 
      .Groupable() 
    ) 

的partia视图,这是MeasureDimension _IndexDimension.cshtml的局部视图

@model CommerceSuite.Web.Models.MeasurementScheme.MeasureDimensionModel 

@(Html.Telerik().Grid<CommerceSuite.Web.Models.MeasurementScheme.MeasureDimensionModel>() 
        .Name("MeasurementScheme")   
      .DataBinding(databinding => { 
       databinding.Ajax().Select("MeasureDimensionView", "MeasurementScheme"); 
      }) 
      .Columns(columns => 
       { 
        columns.Bound(p=>p.MeasureDimensionId) 
        .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= MeasureDimensionId #>' />") 
        .HeaderTemplate(
        @<text> 
         <input type="checkbox" title="Select/Unselect All Records" id="checkAllRecords" /> 
           </text> 
       ) 
        .Title("") 
        .Width(40) 
        .HtmlAttributes(new { style = "text-align:center" }); 
        columns.Bound(p => p.Name).Width(300); 
        columns.Bound(p => p.Symbol).Width(100); 
        columns.Bound(p => p.Ratio).Width(100); 
        columns.Bound(p => p.IsActive).Width(75); 
        columns.Bound(p => p.IsActive).Title("Update").Sortable(false).Filterable(false).Width(50) 
        .ClientTemplate("<img src='../../Content/themes/myicons/edit.png' title='Edit' width='20' onclick='csPopupOpen(\"HELLO\",\"" + @Url.Action("EditDimension") + "\",<#=MeasureDimensionId #>,\"" + @Url.Action("IndexDimension") + "\")' value='Edit' > <img src='../../Content/themes/myicons/del.ico' width='20' title='delete' name='<#=MeasureDimensionId #>' onclick='csPopupOpen(\"HELLO\",\"" + @Url.Action("Delete") + "\",<#=MeasureDimensionId #>)' value='Delete' > ").Width(50); 
       }) 
      .Pageable() 
      .Scrollable() 
      .Sortable() 
      .Groupable() 
    ) 

这就是所有关于它

+0

奇怪,你能发布你的控制器代码和部分视图吗? – Nico

+0

奇怪的是,控制台中是否存在JavaScript错误? –

+0

不,没有在控制台中的错误,还有一件事情,当我改变第二个选项卡上的控制器名称,它工作正常。或者,如果我同时删除的.selected财产,第一我点击比也比它工作在同一个控制器精细第一第二个选项卡,但如果我第一个选项卡上单击比按秒比它不起作用。 –

回答

1

Yeaah我找到了Solutuion

我在这两个,这是错误

@(Html.Telerik().Grid<ProjectName.Web.Models.MeasurementScheme.MeasureDimensionModel>() 
       ***.Name("MeasurementScheme")***//This is the problem 

    @(Html.Telerik().Grid<CommerceSuite.Web.Models.MeasurementScheme.MeasureDimensionModel>() 
       ***.Name("MeasurementScheme")***//same as previous 

我们不能使用网格的相同名称的局部视图使用相同的网格名称。

相关问题