You are on page 1of 3

@model @using @using @using

IEnumerable<EditorTemplateSample.Models.GetNLAggrTrades_Result> Telerik.Web.Mvc.UI; EditorTemplateSample.Models System.Collections;

<script type="text/javascript"> function OnRowDataBound(e) { $(e.row).find('#SellerID').val(e.dataItem['SellerID']); $(e.row).find('#TrancheType').val(e.dataItem['TrancheType']); $(e.row).find('#InterestType').val(e.dataItem['InterestType']); $(e.row).find('#AccrualType').val(e.dataItem['AccrualType']); $(e.row).find('#Index1Code').val(e.dataItem['Ind1Code']); $(e.row).find('#Split').val(e.dataItem['Split']); $(e.row).find('#Index2Code').val(e.dataItem['Ind2Code']); } function convertToDate(date) { var varDate = new Date(date); varDate = (varDate.getMonth() + 1) + '/' + (varDate.getDate()) + '/' + v arDate.getFullYear(); return varDate; } function onDataBinding(args) {debugger; var fromDate = $('#fromDate').data('tDatePicker'); var toDate = $('#toDate').data('tDatePicker'); fromDate = convertToDate(fromDate.value()); toDate = convertToDate(toDate.value()); args.data = $.extend(args.data, { fromDate: fromDate, toDate: toDate }); } function onEdit(e) {debugger; $ddl = $(e.form).find('#Split'); if ($ddl.length > 0) { var ddl = $ddl.data('tDropDownList'); ddl.fill(function () { if (e.dataItem['Split'] != null) { ddl.value(e.dataItem['Split']); } }); } var dataItem = e.dataItem; var mode = e.mode; var form = e.form; if (mode == "insert") { $.ajax({ type:"POST", url: "/EditGrid/_InsertAjaxEditing", data:"customerId=" + "test", success:function (msg) { alert("Data Saved: " + msg); } }); } } </script>

@(Html.Telerik().Grid<EditorTemplateSample.Models.GetNLAggrTrades_Result>() .Name("NotelineFeedAggrGrid") .DataKeys(dataKeys => dataKeys.Add(p => p.IssueID)) .ClientEvents(events => events.OnRowDataBound("OnRowDataBound")) .ClientEvents(events => events.OnDataBinding("onDataBinding")) .ToolBar(commands => { commands.Insert(); }) .Columns(columns => { columns.Bound(c => c.TrancheID).Width(80); columns.Bound(c => c.Split).Title("Split").Width(230); //columns.Bound(c => c.Split).Title("Split").ClientTemplate(Html.Dro pDownList("Split", (SelectList)(ViewData["Split"])) // .ToHtmlString()).Width(180); columns.Bound(c => c.SellerID).Title("Seller ID").ClientTemplate(Htm l.DropDownList("SellerID", (SelectList)(ViewData["SellerID"])) .ToHtmlString()).Width(180); columns.Bound(c => c.IssuanceDate).Width(130); columns.Bound(c => c.MaturityDate).Width(120); columns.Bound(c => c.NetProceeds).Width(80); columns.Bound(c => c.TodaysIssuance).Width(60); columns.Bound(c => c.TradeType).Title("Tranche Type").ClientTemplate (Html.DropDownList("TrancheType", (SelectList)(ViewData["TrancheType"])) .ToHtmlString()).Width(180); columns.Bound(c => c.Dealer).Width(120); columns.Bound(c => c.IntDiscRate).Width(120); columns.Bound(c => c.InterestType).Title("Int Type").ClientTemplate( Html.DropDownList("InterestType", (SelectList)(ViewData["InterestType"])) .ToHtmlString()).Width(180); columns.Bound(c => c.AccrualType).Title("Accrual Type").ClientTempla te(Html.DropDownList("AccrualType", (SelectList)(ViewData["AccrualType"])) .ToHtmlString()).Width(180); columns.Bound(c => c.Ind1Code).Title("Index 1 Code").ClientTemplate( Html.DropDownList("Index1Code", (SelectList)(ViewData["IndexCode1"])) .ToHtmlString()).Width(180); columns.Bound(c => c.Ind2Code).Title("Index 2 Code").ClientTemplate( Html.DropDownList("Index2Code", (SelectList)(ViewData["IndexCode2"])) .ToHtmlString()).Width(180); columns.Bound(c => c.NLBatchID).Width(130).Visible(false); columns.Bound(c => c.AdjIntFlag).Width(130).Visible(false); columns.Bound(c => c.InsertedFlag).Width(130).Visible(false); columns.Bound(c => c.NumSpilts).Width(130).Visible(false); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.Text); }).Width(180).Title("Commands"); //columns.Command(commands => commands.Edit()).Title("Edit").Width(2 00); }) .DataBinding(dataBinding => dataBinding.Ajax()

.Select("_NotelineAggrTrades", "EditGrid") .Update("_update", "EditGrid") .Insert("_InsertAjaxEditing", "EditGrid") ) .ClientEvents(events => events.OnEdit("onEdit")) //.Editable(editing => editing.Mode(GridEditMode.InCell).DefaultDataItem (new GetNLAggrTrades_Result //{ // //LastSupply = DateTime.Today //})) .Editable(editing => editing.Mode(GridEditMode.InLine)) .Pageable() .Scrollable() .Sortable() )

You might also like