Telerik Forums
UI for ASP.NET MVC Forum
2 answers
267 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
870 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
937 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
136 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
161 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
197 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
309 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.3K+ 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
205 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
132 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
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?