Telerik Forums
UI for ASP.NET MVC Forum
6 answers
831 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
903 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
119 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
155 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
172 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
281 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
4 answers
1.2K+ views
I have a grid that is bound to some data that includes a ProjectID and a Project_Name column. The Project_Name column is a lookup into another database table based on ProjectID, but I return it as part of the result set for simpler display and binding in the grid. The grid's edit mode is PopUp and I have created an EditorTemplate with a Kendo ComboBox that is bound to ProjectID for value and Project_Name for display. When you change the ProjectID and click Update, the new ProjectID is persisted in the DB, but the Project_Name value doesn't change unless I refresh the page or the grid. I have all the information that I need to be able to assign the new Project_Name to the row, so I do not want to have to rebind the grid or refresh the page just to do this.

Now, I know that controls in the templated pop-up that are bound to the model will automatically update the grid's dataItem when they change. If I add an Html.TextBoxFor(o => o.Project_Name) to the editor and type a new value into it, I can see it change in the grid at the same time. I was planning to hide this textbox and update its value in JavaScript when the ProjectID's combobox value changes in order to update the grid's dataItem, but after some experimentation, I have found that changing the Project_Name textbox's value with JavaScript does not update the grid's dataItem; only typing into it does. I have tried updating the textbox's value both by using the JQuery val() method and by accessing the HTML input's value property directly. I cannot see any event handlers attached to the textbox, so I don't understand the mechanism by which the value that I type in is sent back to the grid, while a value assigned in JavaScript is not sent back.

So, a few questions:
1. Why does the bound textbox update the grid's dataItem when I type a value in, but not when I assign a value via JavaScript?
2. Is there a way for me to trigger the bound checkbox to update the grid's dataItem after I update the value in JavaScript?
3. Is this the best way for me to update Project_Name in the edited row in the grid, or is there a better way to do so without having to rebind the grid or refresh the page? 
Viktor Tachev
Telerik team
 answered on 25 May 2016
5 answers
192 views

I am binding a ListView to a collection of strings.  How can I access that data in the template definition? Model.SearchResults is a type of IEnumberable<string>

@(Html.Kendo().ListView(Model.SearchResults)
    .Name("listClients")
    .TagName("div")
    .ClientTemplateId("clientsTemplate")
    .Pageable(pageable => pageable
        .PreviousNext(true)
        .Info(true)
        .PageSizes(true))
    .HtmlAttributes(new{style="min-height:300px"})
    .DataSource(dataSource => dataSource
         
        .PageSize(1)))
 
<script type="text/x-kendo-tmpl" id="clientsTemplate">
       @Html.Action("LoadProfileView", new { clientId = **HOW DO I GET THE VALUE HERE**})
</script>

Maria Ilieva
Telerik team
 answered on 25 May 2016
4 answers
121 views

Hi How to draw a fever chart in Kendo bubble chart in ASP.Net MVC . PFA. I would like to draw a background for the buble chart

 

 

I got a code for scatter but it is not working for Buble

 

http://docs.telerik.com/kendo-ui/controls/charts/how-to/draw-on-scatter-plots

Veselin Tsvetanov
Telerik team
 answered on 24 May 2016
5 answers
551 views
Hi,

I'm using a grid with PopUp edit mode, using a template, declared like this:

...
.Editable(editable => editable
.Mode(GridEditMode.PopUp)
.TemplateName("CompanyEditorTemplate")
.Window(w => w.Title("Gestione Cliente")))
...

All works fine. But I'd like to add progress indicator to the window using this kendo.ui.progress($("#gridClienti"), true) but the problem is that I can't retrieve the window div element to pass to this function. I tried to add ID throw HtmlAttributes() method but it doesn't work.

Any suggestion will be appreciated.

Thanks!!
Konstantin Dikov
Telerik team
 answered on 24 May 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?