Hello,
I have a form with different text fields and dropdown lists.
after entering the information, I have a button that allows me to validate the creation of this new element.
this button must call an action of my controller which is used to generate an excel file where I must call the template of this file from my local files and display the information entered in the fields that correspond in the excel file
I am using npoi library (c #) in back and telerik ui for asp.net mvc
It would be much appreciated if you can help me on this.
Thanks for replying
Hi,
I am new to Telerik at. I have a scenario where I click on the grid record I am taken to a form with the values populated. With the help of some online resources I was able to populate when the form and grid was kept in the same view. However, when I have a separate view I don't get my values populated.Where am I going wrong? Any help is greatly appreciated. Thanks in advance
My grid looks like - Index.cshtml
@(Html.Kendo().Grid<
TabGrid.Models.ORM_MT_STATUS
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.STATUS_ID);
columns.Bound(c => c.STATUS_DESCRIPTION);
columns.Bound(c => c.CreatedBy);
columns.Bound(c => c.CreatedDate);
columns.Bound(c => c.CreatedIP);
columns.Bound(c => c.UpdatedBy);
columns.Bound(c => c.UpdatedDate);
columns.Bound(c => c.UpdatedIP);
;
})
.ToolBar(toolbar => {
toolbar.Excel();
})
.ColumnMenu()
.Pageable()
.Navigatable()
.Selectable(selectable => {
selectable.Mode(GridSelectionMode.Single);
selectable.Type(GridSelectionType.Row);
})
.Sortable(sortable => {
sortable.SortMode(GridSortMode.SingleColumn);
})
.Filterable()
.Scrollable()
.Events(events => {
events.Change("onChange");
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ORM_MT_STATUS_Read", "Status"))
)
)
<
script
>
function fillForm(dataItem) {
var columns = $("#grid").data("kendoGrid").options.columns;
var id = dataItem.STATUS_ID;
var form = $("form");
for (var i = 0; i <
columns.length
; i++) {
var
field
=
columns
[i].field;
form.find("#" + field).val(dataItem[field]);
}
//
window.location.href
=
"@Url.Action( "
form", "Status")" + "?STATUS_ID" + id;
}
function onChange(e) {
//var grid = $("#grid").data("kendoGrid");
var
dataItem
=
this
.dataItem(this.select());
fillForm(dataItem);
}
</script>
My form looks like - form.cshtml
@{
ViewBag.Title = "form";
}
<
h2
>form</
h2
>
<
div
class
=
"demo-section k-content capitalize"
>
<
div
id
=
"validation-success"
></
div
>
@(Html.Kendo().Form<
TabGrid.Models.ORM_MT_STATUS
>
()
.Name("form")
.HtmlAttributes(new { action = "form", method = "POST" })
.Validatable(v =>
{
v.ValidateOnBlur(true);
v.ValidationSummary(vs => vs.Enable(true));
})
.Items(items =>
{
items.AddGroup()
.Label("Status Management Form")
.Items(i =>
{
i.Add()
.Field(f => f.STATUS_ID).InputHtmlAttributes(new{ @readonly ="readonly"})
.Label(l => l.Text("ID:"));
i.Add()
.Field(f => f.STATUS_DESCRIPTION)
//.InputHtmlAttributes(class="capitaize")
.InputHtmlAttributes(new { onkeyup = "this.value = this.value.initcaps();" })
.Label(l => l.Text("Status:"));
});
})
.Events(ev => ev.ValidateField("onFormValidateField").Submit("onFormSubmit").Clear("onFormClear"))
)
</
div
>
@*<
div
>@Html.Action("Add")</
div
>*@
<
script
>
function disablefield() {
document.getElementById("id").disabled = true;
}
function onFormValidateField(e) {
$("#validation-success").html("");
}
function onFormSubmit(e) {
e.preventDefault();
$("#validation-success").html("<
div
class
=
'k-messagebox k-messagebox-success'
>Form data is valid!</
div
>");
}
function onFormClear(e) {
$("#validation-success").html("");
}
</
script
>
I have Json in below format (array of arrays) and defined in cshtml as an observableObject. I want to bind it using Kendo Template MVVM.
1. Can some one help how to define the kendo template to display a table using below JSON structure?
2. What should be passed as source in place of ??? So that the template displays accordingly.
3. how can we access the current item in kendo template?
{ "Type": 1, "Data": [{ "Category": "Sample Rows", "Result": [ [{"Name": "Column1", "Value": "Value1"}, {"Name": "Column2","Value": "Value2"}], [{"Name": "Column1","Value": "1"}, {"Name": "Column2", "Value": "2"}] ] } ] }
<script id="table-data-template" type="text/x-kendo-template"> <table> <thead data-template="header-template" data-bind="source: Result[0]" /> <tbody data-template="row-template" class="row-item" data-bind="source: ???"></tbody> </table> </script>
<script id="header-template" type="text/x-kendo-template"> <th data-bind="text: Name"></th> </script>
<script id="row-template" type="text/x-kendo-template"> <tr data-template="column-template" data-bind="source: ???"></tr> </script>
<script id="column-template" type="text/x-kendo-template"> <td data-bind="text: Value"></td> </script>
Hi,
here first am displaying kendo chart with data using read option.
here am applied group and sort to my chart with stack option.
upto here its working fine.
by using kendo multiselect am filtering chart data. so when i apply filtering the stack data is not displaying correctly.
here is my code.
<div class="demo-section k-content wide">
@(Html.Kendo().Chart<TimeControlReportEnhancements.Models.ResourceByProject>()
.Name("chHoursByResource")
.Title("Hours By Resource")
.Legend(false)
//.DataSource("dataSource2")
.DataSource(dataSource => dataSource
.Read(read => read.Action("LoadHoursByResourceWithDetails", "Home"))
.Group(group => group.Add(model => model.Hours))
.Sort(sort => sort.Add(model => model.EmpName).Ascending())
)
.Series(series =>
{
series.Column(model => model.Hours).Name("Hours").CategoryField("EmpName");
})
.SeriesDefaults(s=>s.Column().Stack(true))
.CategoryAxis(axis => axis
//.Name("label-axis")
//.Categories(model => model.EmpName)
.Labels(lbl => lbl.Rotation(-90))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("<p style='width: 200px; text-align: left;'><span style='display: inline-block; font-weight: bold;'>Employee Name:</span> #= dataItem.EmpName #</p>" +
"<p style='width: 200px; text-align: left;'><span style='display: inline-block; font-weight: bold;'>Project Name:</span> #= dataItem.ProjectName #</p>" +
"<p style='width: 200px; text-align: left;'><span style='display: inline-block; font-weight: bold;'>Hours:</span> #= value #")
)
)
</div>
function onSelect(e) {
var chart = $("#chHoursByResource").data("kendoChart");
var dataSource = chart.dataSource;
var dataItem = e.dataItem;
var multiselect = $("#ddlEmpNames").data("kendoMultiSelect");
var selectedData = [];
var items = multiselect.value();
$.each(items, function (i, v) {
selectedData.push(v);
});
selectedData.push(dataItem.EmpName);
var _fltMain = [];
var _flt = { logic: "or", filters: [] };
$.each(selectedData, function (i, x) {
_flt.filters.push({ field: "EmpName", operator: "contains", value: x });
})
_fltMain.push(_flt);
dataSource.query({ filter: _fltMain });
//dataSource.filter({ field: "EmpName", operator: "contains", value: selectedData[0] });
////dataSource.filter({
//// logic: "or",
//// filters: [
//// //{ field: "EmpName", operator: "contains", value: selectedData[0] }
//// ]
////});
var Grid = $("#Grid").data("kendoGrid");
var GriddataSource = Grid.dataSource;
GriddataSource.query({ filter: _fltMain });
$('#Grid').data('kendoGrid').dataSource.group({ field: "EmpName" });
//$('#chHoursByResource').data('kendoChart').setDataSource(GriddataSource);
//$('#chHoursByResource').data('kendoChart').dataSource.group({ field: "EmpName" });
}
Hi,
i want to apply kendo datasource to grid. and i want to apply group by and aggrigate functions inside grid.
Hello,
I am currently evaluating the Telerik control Tree View to display the hiearchy data as shown in the attached screen shot.
I have a requirement where we will be building a treeview in our ASP.NET MVC controller code passing to the view.
I need to display the Kendo Tree View with all nodes expanded when the application loads initially How do I do that ?
Hi,
I am trying to persist my MVC Kendo Grid using getOptions() and setOptions(). I am successfully able to save and get.
Now I am facing problem with Kendo grid columns tooptip and data tooltip while setOptions() loading to my page.
I need to get tooptip on Account Code after loading my user preferences by using setOptions(). Please help me.
Here my code
@(Html.Kendo()
.Grid<Models.TransactionSummary>()
.Name("TransactionDetailGrid")
.Columns(c =>
{
c.Bound(p => p.Account.Code).Width(60);
c.Bound(p => p.VendorInvoiceNumber).Width(80);
}
function SaveUserPrererences() {
var grid = $("#" + SearchResultGridId()).data().kendoGrid;
var resources = kendo.stringify(grid.getOptions());
$.ajax(
{
url: "@Url.Action("SaveUserPreferences", "Review", new { area = "Transaction" })",
type: 'POST',
async: false,
contentType: "application/json; charset:utf",
dataType: 'json',
data: JSON.stringify({ gridResources: resources, isActive: isActive }),
success: function (data) { }
}
$("#load").click(function (e) {
var grid = $("#" + SearchResultGridId()).data().kendoGrid;
e.preventDefault();
$.ajax(
{
url: "@Url.Action("GetUserPreferences", "Review", new { area = "Transaction" })",
async: false,
type: "POST",
dataType: 'json',
success: function (data){
if (data) {
var parsedOptions = JSON.parse(data);
parsedOptions.toolbar = [
{ template: $("#toolbarTemplate").html() }
];
parsedOptions.columns[0].headerTemplate = $("#headerTemplate").html();
grid.setOptions(parsedOptions);
}
}
Hello,
I have a form with different text fields ,dropdown lists and a gridview with some data.
after entering the information in text fields, I have a button that allows me to validate the creation of this new element.
this button must call an action of my controller which is used to generate an excel file where I must call the template of this file from my local files and display the information entered in the fields that correspond in the excel file
I am using npoi library (c #) in back and telerik ui for asp.net mvc
It would be much appreciated if you can help me on this.
Thanks for replying