I have a grid where a button on the form calls addRow(). So the row is in insert mode. How do I prevent the user from leaving the row until the values entered have been entered and are valid. Right now it is showing the hints when the user goes to another column without completing the cell but the user can completely leave the row and it remains empty of values.
Is there a way to call validate before calling grid.saveChanges()?
Hello,
I have the problem that one ForeignKey column depends on another ForeignKey column (see attached picture). As you can see the
columns "Fachgruppe" depends on value in column "Sparte" - now this is not correct because I don't know how to display only the
values for "Fachgruppe" which depends on the current value of column "Sparte" in the row (for display and editing)?
these are sample values for that columns
Sparte Fachgruppe
1 1
1 2
1 3
2 1
2 2
3 1
3 2
Is there a way to do this with MVC Grid?
robert
I have a client side datasource grid with several count and sum aggregates that display their data correctly, but they doesn't update when a user filters a column that affects the result of such aggregates. Is it possible to do that? The only way I can think of is with an event that updates the footer, but I don't know how to achieve this.
My grid was created using razor.
Thanks in advance.
Hi,
I am trying to load SQL server data into a dropdownlist in an MVC project, database
first and it works fine as the long as the table is not joined in the
model diagram.
As soon as i bring other tables that are linked to the
one i need, the dropdown does not load data anymore.
Am I missing something?
How can i solve this?
Thx
Adrian
I am using kendo Grid of kendo of ASP.NET MVC 2016.1.412.
My code where I want to get selected is:
column.Bound(e => e.Username).Title("Username").Groupable(true).ClientTemplate("<a style='cursor:pointer' onclick=EditProductDataObject(Username)>#=Username#</a>");
Here instead of username I want to pass whole row object so I can read and use further the coming data.
I have a very basic grid that I built with the telerik mvc grid scaffolding.
I have a column called "parent" that parent should display a 10 digit number, instead it displays "function (){return o}"
I have tried templating, toString and it shows the same thing. every other column works as expected
@(Html.Kendo().Grid<AccountMove.act_trans_worktable>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.customer_name);
columns.Bound(c => c.reason);
columns.Bound(c => c.parent);
})
.Pageable()
.Navigatable()
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Filterable()
//.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("act_trans_worktable_Read", "mvcgrid"))
)
)
I have a editable Kendo grid with two datepicker inside, the kendo grid and it's controller are part an MVC Area. When i want to save a row the error is shown saying that the value introduced is not valid, i want the date format as dd/MM/yyyy. Those date fields have a template like this:
@(Html.Kendo().DatePicker()
.Name("date")
.Culture("es-MX")
.Format("{0:dd/MM/yyyy}")
.ParseFormats(new string[] { "dd/MM/yyyy" })
)
also in the columns definition have format and even a js function to get the value as i want
.Columns(columns =>
{
columns.Bound(p => p.InicioVigencia).Format("{0:dd/MM/yyyy}").ClientTemplate("#=getDate(InicioVigencia)#");
columns.Bound(p => p.FinVigencia).Format("{0:dd/MM/yyyy}").ClientTemplate("#=getDate(FinVigencia)#");
}
function getDate(object) {
if (object == null || object == "null" || object == "NULL" || object == "Null")
return "";
return kendo.toString(object, "dd/MM/yyyy");
}
In the global.asax i set this properties in order to have the date format i want.
CultureInfo threadCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiCultureInfo = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
threadCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
threadCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
uiCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
uiCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
Thread.CurrentThread.CurrentCulture = threadCultureInfo;
Thread.CurrentThread.CurrentUICulture = uiCultureInfo;
But the system still showing the error, i have other datepickers defined as js in orther controller just like this
$(function () {
$(".date-picker").kendoDatePicker({
animation: {
close: {
effects: "fadeOut zoom:out",
duration: 300
},
open: {
effects: "fadeIn zoom:in",
duration: 300
}
},
format: "dd/MM/yyyy",
culture: "es-MX"
});
});
And everyting is working fine, so i don't know why it is not working properly. if i change global.asax like this
CultureInfo threadCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiCultureInfo = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
threadCultureInfo.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
threadCultureInfo.DateTimeFormat.LongDatePattern = "MM/dd/yyyy hh:mm:ss tt";
uiCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
uiCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
Thread.CurrentThread.CurrentCulture = threadCultureInfo;
Thread.CurrentThread.CurrentUICulture = uiCultureInfo;
the grid that use the templates work properly but the view with the js stop working
I have a scenario where I need a way for the user to cancel an insert once they have chose to insert a new row.
The configuration is InCell editing with a custom "save" button and a custom "add" on top of the view. So the grid is in batch edit mode and is working fine other than when the user decides to insert a row. If I place a default "Cancel" command that cancel button will be in every row. That is one problem.
So I decided to have a hidden column at the end of the grid with a client template containing a "Cancel" button.
When they insert a new row I hook the onEdit event of the grid and make the column visible. But in doing so all of the column widths get whacked out. I searched a bit to find a resize row method but it is not working.
function
resizeColumnDefaults() {
debugger;
resize(0, 250);
resize(2, 100);
resize(3, 100);
resize(5, 100);
resize(6, 100);
resize(8, 120);
resize(9, 300);
resize(10, 75);
resize(11, 75);
resize(13, 75);
}
function
resize(idx, width) {
$(
"#Grid .k-grid-header-wrap"
)
//header
.find(
"colgroup col"
)
.eq(idx)
.css({ width: width });
$(
"#Grid .k-grid-content"
)
//content
.find(
"colgroup col"
)
.eq(idx)
.css({ width: width });
}
function
onEdit(e) {
var
grid = $(
"#Grid"
).data(
"kendoGrid"
);
grid.showColumn(11);
resizeColumnDefaults();
}
Can someone offer a solution?
Thanks,
Reid
Hi,
Whe I hide columns in a sub-grid I get problems with the look of the sub-grid. The reason seems to be that I hide the last column that does not have the width set (to make this column take up the remaining space in the row).
The template for the sub-grid from the cshtml page:
<script id="utförseltemplate" type="text/x-kendo-tmpl">
@(Html.Kendo().Grid<UtförselViewModel>()
.Name("grid_#=Id#")
.TableHtmlAttributes(new { @class = "ansokan-produkter-utforsel-subgrid" })
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden(true);
columns.Bound(p => p.UtförselDiarieNummer).Title("Diarienummer").Width(150);
columns.Bound(p => p.Datum).Format("{0:yyyy-MM-dd}").Title("Utförseldatum").Width(120);
columns.Bound(p => p.DelKvantitet).Title("Levererad kvantitet").Width(120);
columns.Bound(p => p.Enhet).Title("Enhet");
})
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(r => r.Action("ProduktUtförslarRead", "Giltiga", new { produktId = "#=ProduktId#", ansökanProduktId = "#=Id#" }))
.Sort(sort => sort.Add(r => r.Datum).Descending())
)
.Events(events => events.DataBound("UtforslarDataBound"))
.ToClientTemplate()
)
</script>
Part of the javscript ondatabound:
if (some condition) {
this.hideColumn(3);
this.hideColumn(4);
}
When I hide this column the grid looks chopped off. I guess that I
need to set the column width in the javascript, but I have not been able
to figure out how.
Can you help me set the column width in the javascript or set the width of the whole sub-grid?
Best regards,
Henrik