Telerik Forums
UI for ASP.NET MVC Forum
2 answers
143 views

Hi,

I have a DatePicker that displays the date nicely in the correct format i.e. "2016-05-26" for May 26, 2016.

 

I would like to handle badly formatted user input, like "160531" which is an allowed way to enter a date in our organisation. I want to take this date and format it correctly with some JS code. The problem is that when I input a date like this I can't get it from the datepicker in my javascript code.

JS Code:

       var date1 = kendo.toString($("#RelevantDate").data("kendoDatePicker").value(), 'd');
        var date2 = $("#RelevantDate").data("kendoDatePicker").value();

both the date1 and the date2 variable are null if I have a date like "160531". With a nicely formatted date everything works.

 

Is there any way to get a badly formatted date out of the datepicker? I want the users to be able to select the date in the picker and to enter the date manually so changing to a textbox input is not an option.

 

Best regards,

Henrik
 

Henrik
Top achievements
Rank 1
 answered on 27 May 2016
6 answers
232 views

Hello,

 

I have an empty mvc 5 c# project which I basicly put a grid in and that is now working just fine, my problem is styling and its position.

there is no CSS nothing I can see that would make the grid or the .cshtml file behave in this way. It has a margin on the left of about 1/4th of the whole screen.

This is quite annoying , I suspect something in the included stylesheets with the grid is doing this. Its not just the grid this also does the same to the footer that is rendered in the _layout.cshtml.

I want to either put a details column on the left or right of the grid that displays further details about the selected line in the grid.

 

Suggestions ?

 

Regards,

Emil 

 

Konstantin Dikov
Telerik team
 answered on 27 May 2016
4 answers
211 views
I'm using asp.net mvc 4 with a server bound grid.  When the actions are posted to my controller, they do not include the antiforgery token and therefore .net throws up an error.  I've seen examples on how to pass the token with ajax bound grids, but not with server bound grids.  How would this be accomplished?
Brad
Top achievements
Rank 1
 answered on 26 May 2016
2 answers
259 views

I have a grid with a foreign key that is displaying a dropdown in in-line edit mode. That's working fine but I would like to display multiple columns from the parent object in that dropdown not just the key as it currently does. How do I configure for that?

Here's what I have

    @(Html.Kendo().Grid<MBSData.Model.DocumentType>()
          .Name("documenttypegrid")
          .HtmlAttributes(new {style = "height:600px;"})
          .Columns(columns =>
          {
              columns.Bound(c => c.DocumentTypeId).Title("Type").Width("120px");
              columns.ForeignKey(p => p.DocumentCategoryId, (System.Collections.IEnumerable) ViewData["DocumentCategories"], "DocumentCategoryId", "DocumentCategoryId")
                  .Title("Category")
                  .Width("120px");
              columns.Bound(c => c.Description);
              columns.Command(command =>
              {
                  command.Edit();
                  command.Destroy();
              }).Width("190px");
          })
          .ToolBar(toolbar => { toolbar.Create(); })
          .Editable(editable => editable.Mode(GridEditMode.InLine))
          .Sortable(sortable => { sortable.SortMode(GridSortMode.MultipleColumn); })
          .Filterable()
          .Scrollable(s => s.Height("auto"))
          .Resizable(resize => resize.Columns(true))
          .DataSource(dataSource => dataSource
              .Ajax()
              .ServerOperation(false)
              .Model(model => model.Id(p => p.DocumentTypeId))
              .Read(read => read.Action("DocumentType_Read", "DocumentType"))
              .Create(create => create.Action("DocumentType_Create", "DocumentType"))
              .Update(update => update.Action("DocumentType_Update", "DocumentType"))
              .Destroy(destroy => destroy.Action("DocumentType_Destroy", "DocumentType"))
          )
          .Events(events => events
              .Edit("onEdit")
          )
          )

 

Thanks.

Tom

Tom
Top achievements
Rank 1
 answered on 26 May 2016
6 answers
863 views

Hi support,

I need to create a Parent/Child grid and both grids must be editable. I've seen some examples in the forum and non of them fit my scenario.

In my case both grids uses local data binding so there's no need for .Create() .Read() .Update() .Destroy() methods in the datasource. One action return the view with the data needed to show in both grids.

The problem I'm facing is that when I add .Editable(ed => ed.Mode(GridEditMode.InCell)) to the child grid without specifying a datasource I get this error:

    An exception of type 'System.NotSupportedException' occurred in Kendo.Mvc.dll but was not handled in user code
    Additional information: There is no DataSource Model Id property specified.

Now if I add a datasource like the one below nothing is shown in the child grid but the header.

01..DataSource(dataSource => dataSource
02.    .Ajax()
03.    .ServerOperation(false)
04.    .Batch(true)
05.    .Model(model =>
06.    {
07.        model.Id(p => p.ID);
08.    })
09.)

 

I also checked these demos

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/edit-master-row-data-in-detail-template

http://www.telerik.com/support/code-library/grid-ajax-hierarchy-editing

but both use a datasource with .Create() .Read() .Update() .Destroy() operations in the child grid so they're useless to me.

Is it possible to create the child grid editable without CRUD operations in its datasource?

Any help will be appreciated.

PS: I don't even need the Read operation in the datasource because I already have these data!

Here's my code

View:

01.@using TelerikTests.Models
02.@model TestModel
03. 
04.@{
05.    ViewBag.Title = "Home Page";
06.}
07. 
08.@(Html.Kendo().Grid(Model.Categories)
09.    .Name("grid_Parent")
10.    .Columns(columns =>
11.    {
12.        columns.Bound(c => c.ID).Hidden();
13.        columns.Bound(c => c.Description)
14.            .Width(50);
15.        columns.Bound(c => c.DateCategory)
16.            .Format("{0:yyyy/MM/dd}")
17.            .Width(100);
18.    })
19.    .HtmlAttributes(new { style = "height: 380px;" })
20.    .Scrollable(x => x.Height(300))
21.    .Sortable(x => x.SortMode(GridSortMode.MultipleColumn))
22.    .Filterable()
23.    .DataSource(dataSource => dataSource
24.        .Ajax()
25.        .ServerOperation(false)
26.        .Batch(true)
27.        .Model(model =>
28.        {
29.            model.Id(p => p.ID);
30.        })
31.    )
32.    .ClientDetailTemplateId("child")
33.    .Events(e => e.DetailInit("childGridInit"))
34.)
35. 
36.<script id="child" type="text/kendo-tmpl">
37.    @(Html.Kendo().Grid<ProductModel>()
38.        .Name("gridChild_#=ID#")
39.        .Columns(columns =>
40.        {
41.            columns.Bound(c => c.ID).Hidden();
42.            columns.Bound(c => c.Name)
43.                .Width(70);
44.            columns.Bound(c => c.Price)
45.                .Width(70);
46.        })
47.        //.Editable(x => x.Mode(GridEditMode.InLine))
48.        //.DataSource(dataSource => dataSource
49.        //  .Ajax()
50.        //  .ServerOperation(false)
51.        //  .Batch(true)
52.        //  .Model(model =>
53.        //  {
54.        //      model.Id(p => p.ID);
55.        //  })
56.        //)
57.        .ToClientTemplate()
58.    )
59.</script>
60. 
61.<script>
62.    function childGridInit(e) {
63.        var grid = $("#gridChild_" + e.data.ID).data("kendoGrid");
64.        grid.dataSource.data(e.data.Products);
65.    }
66.</script>

 

The model:

01.public class TestModel
02.{
03.    public IEnumerable<CategoryModel> Categories { get; set; }
04.}
05. 
06.public class CategoryModel
07.{
08.    public Guid ID { get; set; }
09.    public string Description { get; set; }
10.    public DateTime DateCategory { get; set; }
11.    public IEnumerable<ProductModel> Products { get; set; }
12.}
13. 
14.public class ProductModel
15.{
16.    public Guid ID { get; set; }
17.    public DateTime DateProduct { get; set; }
18.    public string Name { get; set; }
19.    public decimal Price { get; set; }
20.}

Denlys
Top achievements
Rank 1
 answered on 26 May 2016
1 answer
931 views

I have a mvc grid with as model { int projectnumber, int Monday }

and code

columns.Bound(c => c.Monday).Title(text: "Monday").ClientFooterTemplate(template: "#=sum#");

.DataSource(datasource => datasource
        .Ajax()
        .Aggregates(aggregates =>
        
{
            aggregates.Add(a => a.Monday).Sum();
        })

Now I only want to create the sum over all lines in the grid with exception of the line with project number 1.

 

The AJAX read gets back [1,1] and [2,4] and [3,5] So I hope to get a sum of 4+5=9 instead of the 10 I get with a normal sum.

 

I hope myu question is clear and somebody knows how to do a partial sum.

 

With kind regards,

Maurice Lucas

 

Viktor Tachev
Telerik team
 answered on 26 May 2016
3 answers
128 views

Good day,

The spreadsheet control doesn't seem to support nested VLOOKUPS eg

=IFERROR(IFERROR(VLOOKUP(alt_ref&"/"&supplierID&"/"&LEFT(courseCode,4)&"*",Calcs!A:G,6,FALSE),VLOOKUP(alt_ref&"/"&supplierID&"/",Calcs!A:G,6,FALSE)),VLOOKUP(alt_ref&"//",Calcs!A:G,6,FALSE))

This works correctly in Excel.

 

Regards

Derek

 

Alex Gyoshev
Telerik team
 answered on 26 May 2016
2 answers
159 views

I have an ajax connected grid, and I have a button thats a submit button, when I click it it posts the page and the searchstring I have in a textbox.

This is fine and works, I was just wondering if and how I can with jquery get the button to get ajax to fetch the data for the grid? I would like that to happen without a postback if possible, and it should since its an ajax grid.

any ideas ?

 

Regards,

Emil

 

Emil
Top achievements
Rank 1
 answered on 26 May 2016
1 answer
194 views
When I change the start date of a task in the tree list on the left, the end date is automatically updated. It seems that the system keeps the same number of days between the two dates, but not always. However, if I change the start date in the task editor window (double-click on task bar on the right-hand side), the end date does not get updated by the system. This appears to be inconsistent and undesired behavior. How can I suppress the automatic update of the end date when I change the start date?
Bozhidar
Telerik team
 answered on 26 May 2016
2 answers
305 views
HI

I found that Project Template maybe not installed correctly while install new version of 
UI for ASP.NET MVC : 

Project Templates of UI for ASP.NET MVC are disappeared after UI for ASP.NET MVC installation.
After restart the Visual Studio the problem is the same.

Why ? Is there have any solution ?

Best regards

Chris

--

Windows 7
Visual Studio 2015
.NET Framework 4.6
Momchil
Telerik team
 answered on 25 May 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?