0

In my web application User can Add New Tabs

TabModel 

{
public string TabName {get; set;}
public List<SubTabModel> Subs {get; set;}
}

Each Tab can contain List of SubTabs

SubTabModel
{
public string SubTabName {get ; set;}
}

How to perform usabilty of Adding Sub Tabs, and get fully functionality of Requirement attribute and Posting this Tab model with her SubTabs and proceed?

  • 1
    Refer [here](http://stackoverflow.com/questions/29161481/post-a-form-array-without-successful/29161796#29161796) and [here](http://stackoverflow.com/questions/28019793/submit-same-partial-view-called-multiple-times-data-to-controller/28081308#28081308) for some options –  Oct 28 '15 at 09:05

2 Answers2

0
SubTabModel
{
public string SubTabName {get ; set;}
public T RelatedModel {get ; set;}
}

You need to use generic related mvc model with you can apply Validations. You can do like that.

Parth Trivedi
  • 3,732
  • 18
  • 36
0

I hope the following will help you

Partial View

@model List<TabModel>

@{
    <ul>
        @foreach (var item in Model)
        {
            <li>
                <a>@item.TabName</a>
                @if (item.Subs != null)
                {
                    <ul>
                        @foreach (var subItem in item.Subs)
                        {
                            <li>
                                <a>@subItem.SubTabName</a>
                            </li>
                        }
                    </ul>
                }
            </li>
        }
    </ul>
}

Controller

   return PartialView("PartialViewName", TabModel);
Golda
  • 3,449
  • 10
  • 31
  • 62
  • This logic don't allow me dynammicaly add SubTabs by User. It will work for showing it or editing. Because List also added. I want some logic like this` Html.Textboxfor(m=>m.add(new SubModel{Name}) or somehow – Alexandr Sargsyan Oct 29 '15 at 06:50
  • @AlexandrSargsyan, Are you want to add new sub menu from partial view? – Golda Oct 29 '15 at 09:06
  • I want working tehcnic, maybe with partials maybe no, I do it with some jquery features like clone element , but problem, is that the cloning same partial view and change name indexes n to n+1 ex. : SubTabModel[0].Name to Sub.TabModel[1].Name, it works fine, binding in model works and my list fill with two items, but in this case Requirement attribute works only for first element . – Alexandr Sargsyan Oct 31 '15 at 08:20