Hi ,
I have a Grid with Data binded and Save button outside the grid , i need to POST the grid data from view to controller action method in Save button click, i am getting count 0 in the list in the action method when POST. Is there a way to read grid data and get as list, i want in server side.
Note the Grid is inside tabstrip control
Help will be appreciated!!
Hi All
We have observed that if grid is filtered and user hits on add row button. The new row is added but is not visible. Which makes no good sense as user then keeps on hitting add row but doesn't see anything moving.
Is there a way wherein we can make newly added row visible even if there is a filter applied.
Thanks
M.
I have a kendo grid that contains a ClientDetailTemplateId. The Client Details grid contains a column in which the data type from the model is set to Datatype.Password. The grid is also set up for InCell editing.
When the detail grid shown, all values in the Password column are visible in plain text. When I click in the cell, the password is then converted to the typical password field characters to hide the password. When I click out of the cell, the changes are shown in plain text again.
How can I prevent the password column from showing the passwords in plain text when not in 'edit' mode. I thought that adding the Datatype attribute to the view model would handle this, but apparently only in edit mode.
Regards,
Shawn
Hello, I recently update the Kendo version of my project to 2016.1.226.545, and after that I can't show the data on the grids i have, the first time a page load the grid is empty, if I click any column, like sorting the grid, display a Json Object on the screen. Am I losing a js file to add or has anyone an idea what could be happening? Before the update the code was working perfectly.
Here is how i am doing the code,
View
@(Html.Kendo().Grid<Project.Models.Products>()
.Name("Products")
.Scrollable()
.Sortable()
.EnableCustomBinding(true)
.HtmlAttributes(new { style = "height:auto;" })
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(x => x.Code);
})
.ServerOperation(false)
.PageSize(20)
.Read(read => read.Action("LoadProducts", "Products"))
)
.Columns(columns =>
{
columns.Bound(p => p.Product).Title("Product").Width(70);
columns.Bound(p => p.Code).Title("Code").Width(70);
columns.Bound(p => p.Description).Title("Description").Format("{0:0,0.0}").Width(250);
}))
Controller
public ActionResult Products()
{
return View();
}
public ActionResult LoadProducts([DataSourceRequest]DataSourceRequest request)
{
clsData cns = new clsData();
IQueryable<consultProducts> s2 = cns.getProducts().ToList().AsQueryable();
DataSourceResult result = s2.ToDataSourceResult(request, p => new Products
{
Code= p.code,
Product= p.product,
Description= p.description,
});
return Json(result, JsonRequestBehavior.AllowGet);
}
And the result is a Json object like this
{"Data":[{"Code":0001,"Description":"Natural oil","Product":01}],"Total":1,"AggregateResults":null,"Errors":null}
I am new to MVC and really new to using the Telerik tools. I have a grid made in my HTML and the headers come up and no data. I would like to get the data to show up in the Grid. I am sure I need to add something to the controller, just do not know what. I have looked all over and I am getting information overload. Here is what I have in my grid, what do I need in my controller?:
@(Html.Kendo().Grid<CertificateTrackingSystem.Models.Status>
()
.Name("StatusGrid")
.Columns(columns =>
{
columns.Bound(c => c.statusID)
.Visible(false).IncludeInMenu(true)
.Title("ID").Width(30);
columns.Bound(c => c.NameofStatus)
.Title("Status Name").Width(70);
//columns.Command(commands =>
//{
// commands.Edit().Text(" ".).UpdateText(" ").CancelText(" ");
// commands.Destroy().Text(" ");
//}).Title("Actions").Width(150);
}
)
.Filterable(ftb => ftb.Mode(GridFilterMode.Menu))
.DataSource(dataSource =>
dataSource.Ajax()
.Sort(sort => sort.Add("Status").Descending())
.Model(model =>
{
model.Id(Status => Status.statusID);
model.Field(Status => Status.NameofStatus).Editable(false);
}
)
)//.Events(e => e.sync("sync_handler"))
// .Create(create => create.Action("AddComments", "Document", new { areas = "Document", docID = @documentID, docRev = @documentRev }).Data("GetRequestToken"))
// .Read(read => read.Action("ReadComments", "Document", new { areas = "Document", documentID = @documentID, documentRev = @documentRev }).Type(HttpVerbs.Get))
// .Update(update => update.Action("UpdateComments", "Document",new { areas = "Document" }).Data("GetRequestToken"))
// .Destroy(destroy => destroy.Action("DeleteComments", "Document", new { areas = "Document"}).Data("GetRequestToken"))
// .PageSize(5)
// .ServerOperation(false)//.Pageable(x => x.PageSizes(new List<object> { 5, 10, 20, 50, "all" }).Refresh(true))
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Comments"))
//.Sortable()
)
I have a Grid with foreign key column 'Products' with custom editor template. There is a separate button 'Add new Product; which opens up a modal to add new product . After adding new product when I try to create a new record in the Grid and select the newly added product, it shows up as blank in the Grid. When I refresh the page it shows up then. What I am missing?
Foreign key in grid:
columns.ForeignKey(c => c.ID, (System.Collections.IEnumerable)ViewData["products"], "ID", "ProductName").Title("Product")..EditorTemplateName("RemoteForeignKeyProducts).
'RemoteForeignKeyProducts' is the custom editor template for products:
@model object
@(Html.Kendo().DropDownListFor(m => m)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetProducts", "Home").Type(HttpVerbs.Post);
}).ServerFiltering(false);
})
.DataValueField("ID")
.DataTextField("ProductName")
)
GetProducts() is a function in controller
public ActionResult GetProducts()
{
using ( var db = new Entities())
{
var objects = db.Products.Select(p => new { p.ID, p.ProductName}).ToList();
return Json(objects);
}
}
Hello everybody,
I need help about ClientTemplate usage cause I really can't solve this problem lookig for solution online.
My goal is:
1) To have the content of a grid saved inside a IEnumerable inside the model, and be able to submit the model (with populated IEnumerable)
2) To have a grid column that can contain different data filed ComboBox(), Numeric or string
For achiving goal 1 I'm tring following this exaple: https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/submit-grid-with-form
that use #index(data)# inside the ClientTemplate to save a value to the model ienumerable field,
but that give me an erro, for example using:
(@Html.Kendo().TextBox().Name("ParameterListForCycleTime[#index(data)#].Value")).ToClientTemplate()
function index(dataItem) {
var data = $("#wizardGrid").data("kendoGrid").dataSource.data();
return data.indexOf(dataItem);
}
when I try to access the page it gives me the error: index not defined, and I can't understand why.
As you can see in the code index function is defined in script..
2) If I avoid error of point 1 inserting a static 0 index instead of #index(data)# (or I use another Name) once i load the page I see only big textboxs. Clicking near them make them become what I defined in the ClientTemplate (Checkbox,numericBox or normal textbox): https://gyazo.com/7075e354d62758b4a2618f471d463757
(@Html.Kendo().NumericTextBox().Name("ParameterListForCycleTime[0]).Value(0)).ToClientTemplate()
Really hope somebody can help me cause I'm losing my mental sanity on this..
Thanks,
Gabriele
Here the full grid code:
@using (Html.BeginForm("Wizardpage1Result", "CycleTime"))
{
@(Html.Kendo().Grid(Model.ParameterListForCycleTime)
.Name("wizardGrid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Width(180).EditorTemplateName("ReadOnlyTemplate");
columns.Bound(p => p.Description).Width(300).EditorTemplateName("ReadOnlyTemplate");
columns.Bound(p => p.UM).Width(100).EditorTemplateName("ReadOnlyTemplate");
columns.Bound(p => p.Mandatory).Title("Mandatory").Width(100).ClientTemplate("<
input
type
=
'checkbox'
#= Mandatory ?
checked
=
'checked'
:'' # />");
columns.Bound(p => p.Value).Title("Value").ClientTemplate(
"# if (Type == 'LIST') { #" +
(@Html.Kendo().ComboBox()
.Name("ParameterListForCycleTime[#index(data)#].Value")
.Placeholder("Select relationship...")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(new List<
SelectListItem
>() {
new SelectListItem()
{
Text = "Option1",
Value = "1"
},
new SelectListItem()
{
Text = "Option2",
Value = "2"
},
new SelectListItem()
{
Text = "Option3",
Value = "3"
},
new SelectListItem()
{
Text = "Option4",
Value = "4"
}
}).Value("")).ToClientTemplate()
+ "# } else if (Type == 'NUMERIC') { #" +
(@Html.Kendo().NumericTextBox().Name("ParameterListForCycleTime[#index(data)#].Value").Value(0)).ToClientTemplate()
+ "# } else { #" +
(@Html.Kendo().TextBox().Name("ParameterListForCycleTime[#index(data)#].Value")).ToClientTemplate()
+ "# } #"
);
/*"#= Value #" + "<
input
type
=
'hidden'
name
=
'ParameterListForCycleTime[#= index(data)#].Value'
value
=
'#= Value #'
/>")*/
})
.ToolBar(toolbar =>
{
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Events(x => x.DataBound("onDataBound"))
.Navigatable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax().Group(g => g.Add(c => c.Category))
.Batch(true)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.ID);
model.Field(p => p.ID).Editable(false);
model.Field(p => p.Description).Editable(false);
model.Field(p => p.UM).Editable(false);
model.Field(p => p.Mandatory).Editable(false);
model.Field(p => p.Value);
})
.Update("Wizard_Update", "CycleTime")
)
)
<
input
type
=
"submit"
value
=
"SaveModel"
/>
}
<
script
type
=
"text/javascript"
>
function index(dataItem) {
var data = $("#wizardGrid").data("kendoGrid").dataSource.data();
return data.indexOf(dataItem);
}
function onDataBound(e) {
var gridData = this.dataSource.view();
for (var i = 0; i <
gridData.length
; i++) {
var
currentUid
=
gridData
[i].uid;
var
currenRow
=
this
.table.find("tr[
data-uid
=
'" + currentUid + "'
]");
$(currenRow).find(".chkbxCliEditRights").attr("disabled", true);
}
$('#wizardGrid script').appendTo(document.body);
var item = $('#wizardGrid').data().kendoGrid.dataItem($(this.element).closest('tr'));
item.set('Value', this.value());
}
</script>
I'm using "kendo-upload" in my Angular application. I able to upload files upto 125 mb, but i try to upload files like 500MB, 1GB etc, its not going through.
Is there filesize limitations on "kendo-upload", Do i need set any settings for uploading such large files ?
Hi,
I'm using the currently using the Grid with server side processing, grouped by Project Name, and using the ClientGroupFooterTemplate to display totals. This works great, but is there a way to add a sub-total row, for some other calculations?
I'm currently querying the items needed and then query the sub-totals row then concatenating the queries this is drastically slowing the load time.
Any ideas?
public
ActionResult ProjectTaskListAjax(Guid id, [DataSourceRequest] DataSourceRequest request)
{
var tasks = DataService.GetQueryableProjectTasksByUploadId(id);
var queries =
new
[]
{
// This gets all the current tasks
tasks.Select(x =>
new
GridProjectTaskModel
{
[...]
LabourCostTotal = x.LabourCostTotal,
MaterialCostTotal = x.MaterialCostTotal,
[...]
}),
// This gets all the tasks then groups by the Project and then calculates two columns that need to be displayed on the 'sub-total' row.
tasks.GroupBy(x => x.Project.Name).Select(g =>
new
GridProjectTaskModel
{
[...]
LabourCostTotal = g.FirstOrDefault().PurchaseOrders.Where(x => x.SupplierType ==
"Sub-Contract Labour"
).Sum(x => x.TotalEx),
MaterialCostTotal = (g.FirstOrDefault().PurchaseOrders.Where(x => x.SupplierType ==
"Sub-Contract Labour"
).Sum(x => x.TotalEx) * -1),
[...]
})
};
// Concat vs Union makes no difference here
var mergedQuery = queries.Select(query => query.AsEnumerable()).Aggregate(Enumerable.Union);
return
Json(mergedQuery.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}