I have a simple form:
@Model MyViewModel
<form method="post" action='@Url.Action("Submit")'>
<div class="demo-section k-content">
@Html.TextBoxFor(x => x.SomeRequiredField);
@(Html.Kendo().Upload() .Name("files") .HtmlAttributes(new { aria_label = "files" }) )
<p style="padding-top: 1em; text-align: right"><input type="submit" value="Submit" class="k-button k-primary" /></p>
</div>
</form>
public ActionResult Submit(MyViewModel vm, IEnumerable<HttpPostedFileBase> files){
if(ModelState.Valid) {
... do stuff
} else {
return View(vm);
}
}
If I select a bunch of files in my upload control, and push the Submit button, suppose validation failed and the view is posted back, however my selected files are lost and I have to reselect them.
How do I restore the previously selected files in the file upload control (synchronous mode) when the form fails validation and is posted back?
The grid ignore case sensitive by default. But when i try to export excel by server side, the datas are filtered but without ignoring the case.
Any thing to do ?
@(Html.Kendo().Grid(Model)
.Name("grid")
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<a class='k-button k-grid-export' title='Export to XLS'>Export vers Excel</a>
</text>);
})
.Columns(columns =>
{
columns.Bound(prat => prat.FirstName);
columns.Bound(prat => prat.LastName);
}
.ColumnMenu()
.Groupable()
.Excel(excel => excel.FileName("Stat.xlsx").Filterable(true).AllPages(true))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.GUIDReference))
.Read(read => read.Action("DataRead", "BackOffice"))
.ServerOperation(false)
)
$(".k-grid-export").on("click", function (e) {
exportToExcel('XLSX');
});
function exportToExcel(format) {
var grid = $("#grid").data("kendoGrid");
var filteredDataSource = new kendo.data.DataSource({
data: grid.dataSource.data(),
filter: grid.dataSource.filter(),
});
filteredDataSource.read();
var filteredData = filteredDataSource.view();
var exportOption = {
format: format,
title: "Export",
createUrl: "/BackOffice/Export",
downloadUrl: "/BackOffice/Download"
}
data = {
model: JSON.stringify(grid.columns),
data: JSON.stringify(filteredData.toJSON()),
format: exportOption.format,
title: exportOption.title
};
$.post(exportOption.createUrl, data, function () {
window.location.replace(kendo.format("{0}?format={1}&title={2}",
exportOption.downloadUrl,
exportOption.format,
exportOption.title));
});
}
I am trying to implement a DropDownTree on a Grid Editing Popup.
1: I am unable to make the DefaultValue work. I am using an ID Like so: m.Field(p => p.treeID).DefaultValue(3)
2: Selecting another value in the tree does not seem to change the value in the related Grid Cell.
I am a little surprized to see that the dropdowntree selects values with string values rather than with id's.
What if you have the same string value more than once in the tree?
How can I set the value of the dropdowntree with an id?
I have a page that contains a parent grid and a child details grid. The parent grid uses popup editing and I can control the maxLength of the edit fields on the dialog. However, the child details grid allows inline editing and one of the fields ("Code") can only be a length of 3 digits.
I have seen other posts and examples using the .attr to set the element's maxlength, but this does not seems to work.
So, within my details grid there is a column called 'Code'. Inspecting the element while viewing the page in Chrome, shows the edit field to be an <input> element with and Id = 'Code' and Name = 'Code'. I have tried the following jquery within the DataBound event of the details grid. I also tried this in the document.ready function.
$("#Code").attr('maxlength', '3');
and
$("input[name='code']").attr('maxlength', '3');
Any chance of getting this as part of the grid declaration, possibly along with the column.Bound()?
Thanks,
Shawn
Is there a way to make something like this with MVC controls or Kendo UI :
https://demos.telerik.com/aspnet-ajax/fileexplorer/examples/client-sideapi/fileselectordialog/defaultcs.aspx
Thanks for your help.
Hi,
When I upload a file using the Upload control, I want to be able to change the name of the file on the server, but I want the user to see the original file name.
Is there a way to have a different name and value for each file in the list? If so, how is the value set?
Thanks,
Jess
I apologize if this is a silly question but is it possible that a single grid that has the inline editing capabilities for logged in users and just a read only grid for everyone else? If so where do I start?
Looking at the demo I thought I would have to create 2 grids and password-protect the one with inline-editing.
Thanks in advance