This is typical example from telerik, I try create template for nested grid but without success
#(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.FirstName).Width(110);
})
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("HierarchyBinding_Employees", "Grid"))
)
.Events(events => events.DataBound("dataBound"))
)
<script id="template" type="text/kendo-tmpl">
#(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
.Name("grid_#=EmployeeID#")
.Columns(columns =>
{
columns.Bound(o => o.OrderID).Width(110);
columns.Bound(o => o.ShipCountry).Width(110);
columns.Bound(o => o.ShipName).Width(200);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
)
.ToClientTemplate()
)
</script>
How create client template for nested grid? Because columns.Bound(o => o.OrderID).ClientTemplate("#=OrderID# - #=ShipName#") not work.
Try to use without hashtag in
columns.Bound(o => o.OrderID).ClientTemplate("OrderID - ShipName")
Conditional client template in Razor hierarchical grid
Somewhat late, but for anyone who search for this answer too:Escape the template expression, to be evaluated in the child/detail context
Ex:
columns.Bound(o => o.OrderID).ClientTemplate("\\#=OrderID\\# - \\#=ShipName\\#")
Hierarchy Demo MVC with client template on child
Related
I try with the next code:
In the form builder
->add('daterange', DateType:class, array(
'widget' => 'single_text',
'attr' => ['class' => 'js-daterangepicker'],
'html5' => false,
))
And the javascript
$('.js-daterangepicker').daterangepicker({
});
This code works, but retrieve data invalid as validator result.
Is DateType the class? How do I recover the selected data in the widget?
I have created a form through structure in backened
1. field_dimensions from physcial module.
2. then added image field field_image
3. through form_alter added ajax button. below mention
$form['getquote_fs']['getquote']['get-quote-btn'] = array(
'#type' => 'button',
'#name' => 'estimate',
'#button_type' => 'button',
'#executes_submit_handler' => false,
'#limit_validation_errors' => array(array('field_dimensions')),
'#size' => 5,
'#weight' => 100,
'#default_value' => '<span class="bold sd-red">get</span> <span class="normal sd-orange">estimate</span>',
'#maxlength' => 5,
'#description' => t('an industry estimate of how much would I pay.'),
'#ajax' => array(
'callback' => 'custom_startrack_ajax_cal',
'method' => 'replace',
'prevent'=> 'sumbit',
),
);
Now when inside the form if I browse image and press either of the other ajax button.Its directly uploading the image.How i can remove it from being uploading in folder
you can disable the behavior of buttons easily with jquery.
try one of these:
$("#your-button-id").submit(function(e){
return false;
});
or
$("#your-button-id").submit(function(e){
e.preventDefault();
});
I have a kendoui grid that is being generated with this:
<div id="clientsDb">
#(Html.Kendo().Grid<example.OpenAccess.OBClientSetup>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(obcs => obcs.ProfileName).Width(140);
columns.Bound(obcs => obcs.Default).Width(190);
columns.Bound(obcs => obcs.EEFinalize).Width(100);
columns.Bound(obcs => obcs.Completed).Width(110);
columns.Command(command => { command.Edit(); command.Destroy(); });
})
.Groupable()
.Pageable()
.Sortable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("OB2_ClientProfiles", "OB"))
.Update(update => update.Action("EditingInline_Update", "OB"))
.Destroy(update => update.Action("EditingInline_Destroy", "OB"))
.Model(model => model.Id(obcs => obcs.SetupID))
)
)
</div>
With this I cannot figure out how to style the columns.Bound(obcs => obcs.Default).Width(190); select inputs in the column. Its a select input dropdown but i haven't figured out how to style with form-control out of bootstrap. or even its own style from a temmplate within the grid code.
columns.Bound(obcs => obcs.Default)
.Width(190)
.HtmlAttributes(new {#class = "form-control "});
You can add any attributes using the HtmlAttributes Function
I need to get the sum value of multiple fields, I know how to do one but not sure how to do multiple. What I have is this :
#(Html.Kendo().Grid(Model.Result)
.Name("grid1")
.Columns(col =>
{
col.Bound("Date").Format("{0:n2}").Format("{0:d}");
col.Bound("ClientAge").Format("{0:n2}");
col.Bound("PartnerAge").Format("{0:n2}");
col.Bound("TotalGrossIncome").Format("{0:n2}");
col.Bound("TotalExpenditure").Format("{0:n2}");
col.Bound("TotalNetIncome").Format("{0:n2}");
col.Bound("TotalAssets").Format("{0:n2}");
col.Bound("TotalLiabilities").Format("{0:n2}");
col.Bound("TotalNetAssetValue").Format("{0:n2}");
}
)
.Scrollable()
.Selectable(select => select.Mode(GridSelectionMode.Single))
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(p => p.Date))
).Deferred(true)
)
I basically need the sum value in the footer for following
col.Bound("TotalGrossIncome").Format("{0:n2}");
col.Bound("TotalExpenditure").Format("{0:n2}");
col.Bound("TotalNetIncome").Format("{0:n2}");
col.Bound("TotalAssets").Format("{0:n2}");
col.Bound("TotalLiabilities").Format("{0:n2}");
col.Bound("TotalNetAssetValue").Format("{0:n2}")
Can anyone assist me with this please not a kendo guru yet :(
So I managed to get it sorted :D Have a look below. According to Kendo's Documentation the Template is actually incorrect - using #=sum# is referring to client side as to the initial example for ASP.net. I approached this with a different method and working find now.
#(Html.Kendo().Grid(Model.Result)
.Name("grid1")
.Columns(col =>
{
col.Bound("Date").Format("{0:n2}").Format("{0:d}").FooterTemplate("TOTALS");
col.Bound("ClientAge").Format("{0:n2}");
col.Bound("PartnerAge").Format("{0:n2}");
col.Bound(p => p.TotalGrossIncome).Format("{0:n2}").FooterTemplate(#<text>#item.Sum.Format("{0:c}")</text>);
col.Bound(p => p.TotalExpenditure).Format("{0:n2}").FooterTemplate(#<text>#item.Sum.Format("{0:c}")</text>);
col.Bound(p => p.TotalNetIncome).Format("{0:n2}").FooterTemplate(#<text>#item.Sum.Format("{0:c}")</text>);
col.Bound(p => p.TotalAssets).Format("{0:n2}").FooterTemplate(#<text>#item.Sum.Format("{0:c}")</text>);
col.Bound(p => p.TotalLiabilities).Format("{0:n2}").FooterTemplate(#<text>#item.Sum.Format("{0:c}")</text>);
col.Bound(p => p.TotalNetAssetValue).Format("{0:c}").FooterTemplate(#<text>#item.Sum.Format("{0:c}")</text>);
})
.Pageable()
.Selectable(select => select.Mode(GridSelectionMode.Single))
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(p => p.Date))
.PageSize(100)
.Aggregates(aggregates =>
{
aggregates.Add(p => p.TotalGrossIncome).Sum();
aggregates.Add(p => p.TotalExpenditure).Sum();
aggregates.Add(p => p.TotalNetIncome).Sum();
aggregates.Add(p => p.TotalAssets).Sum();
aggregates.Add(p => p.TotalLiabilities).Sum();
aggregates.Add(p => p.TotalNetAssetValue).Sum();
})
)
.Deferred(true)
)
I have this grid
#(Html.Kendo().Grid<Models.Worker>()
.Name("Grid")
.Columns(columns =>
{
//columns.Bound(p => p.UserCard);
columns.ForeignKey(p => p.SecId, (List<UserCard>)ViewData["cards"], "Id", "Code").EditorTemplateName("GridForeignKey");
columns.Bound(p => p.FirstName);
columns.Bound(p => p.LastName);
columns.Bound(p => p.SecondName);
columns.Bound(p => p.Phone);
columns.Bound(p => p.Email);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(220);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp)
.DisplayDeleteConfirmation(true)
.Window(window=> window.Width(470))
)
Grid show ForignColumn excelent
but when I try edit row in window my column SecId show like textblock not like combobox.
EditorTemplateName("GridForeignKey")
this template placed in View/Shared/EditorTemplate/ and I didn't change it.
I just start create web apps and use telerik controls for asp.net so please help me understand what I do wrong.