Hi ,
I have a Model which have a complex structure/nested objects.
Account object have child objects called Addresses.
Like Account.Addresses[0].StreetName etc.
How can i set Addresses from editor popup custom template so i get the list from controller to update or insert.
My Controller :
My custom Template :
My Grid :
I have a Model which have a complex structure/nested objects.
Account object have child objects called Addresses.
Like Account.Addresses[0].StreetName etc.
How can i set Addresses from editor popup custom template so i get the list from controller to update or insert.
My Controller :
[HttpPost]
public ActionResult AccountPopup_Create([DataSourceRequest] DataSourceRequest request, Account account )
{
var result;
return new JsonResult() { Data = result };
}
[HttpPost]
public ActionResult AccountPopup_Update([DataSourceRequest] DataSourceRequest request, Account account )
{
var result;
return new JsonResult() { Data = result };
}
@model Account
<
table
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Dosya Adı
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Name, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Kaynak Adı
</
td
>
<
td
class
=
"editor-field"
>
@Html.DropDownListFor(model => model.SourceId, new SelectList(GetSources(), "IntId", "Name"), new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Kaynak Profil Id
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.SourceAccountId, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Vergi Dairesi
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.TaxOffice, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Vergi Numarası
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.TaxNo, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Web Sitesi
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Website, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>E-Posta
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.EMail, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Telefon Numarası
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Tel, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Fax
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Fax, new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Profil Çeşidi
</
td
>
<
td
class
=
"editor-field"
>
@Html.DropDownListFor(model => model.AccountType, new SelectList(ConfigModel.EnumToSelectList(typeof(AccountType)), "Value", "Text"), new { disabled = "disabled" })
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Senaryo Tipi
</
td
>
<
td
class
=
"editor-field"
>
@Html.DropDownListFor(model => model.ScenarioType, new SelectList(ConfigModel.EnumToSelectList(typeof(ScenarioType)), "Value", "Text"))
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
style
=
"height: 10px;"
></
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
style
=
"padding-left: 20px;"
><
strong
>Adres</
strong
></
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
style
=
"height: 10px;"
></
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Bina Adı
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Addresses[0].CityName)
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Hesap Adı
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Addresses[0].AccountId)
</
td
>
</
tr
>
<
tr
class
=
"nameEditor"
>
<
td
class
=
"editor-label"
>Mahalle Adı
</
td
>
<
td
class
=
"editor-field"
>
@Html.TextBoxFor(model => model.Addresses[0].CitySubdivisionName)
</
td
>
</
tr
>
</
table
>
@(Html.Kendo().Grid(GetAccounts(AccountType.Customer))
.Name("accountsGrid")
.Columns(columns =>
{
columns.Bound(Account => Account.Name).HeaderTemplate("Profil Adı").Filterable(filterable => filterable.UI("accountNameFilter")).HtmlAttributes(new { title = " #= Name # " });
columns.Bound(Account => Account.TaxNo).HeaderTemplate("Vergi No").Filterable(filterable => filterable.UI("taxNoFilter")).Width(120);
columns.ForeignKey(Account => Account.SourceId, GetSources(), "IntId", "Name").Title("Kaynak Adı").Width(200);
columns.Bound(Account => Account.AccountType).HeaderTemplate("Hesap Tipi").Width(120);
columns.Command(command => { command.Edit().Text("Güncelle").UpdateText("Güncelle").CancelText("İptal"); }).Width(105);
})
.Filterable(filterable => filterable
.Extra(false)
)
.ToolBar(toolbar => toolbar.Create().Text("Yeni kayit ekle"))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("AccountEditPopup"))
.Pageable(pager => pager
.Messages(messages => messages.Display("{0} - {1}. Toplam {2} kayıt")
.ItemsPerPage("")
.First("İlk sayfa")
.Last("Son sayfa")
.Next("Sonraki")
.Page("Sayfa")
.Previous("Önceki")
.Refresh("Yenile"))
)
.Sortable()
.Scrollable()
.Events(e => e.Edit("onEdit"))
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(30)
.Model(model =>
{
model.Id(p => p.IntId);
})
.Events(events => events.Error("error_handler"))
.Create(update => update.Action("AccountPopup_Create", "Config"))
.Read(read => read.Action("AccountPopup_Read", "Config"))
.Update(update => update.Action("AccountPopup_Update", "Config"))
)
)