Telerik Forums
UI for ASP.NET MVC Forum
1 answer
366 views

I created a grid with detail rows. Detais rows may have unsaved data. In that case I need to stop the collapse event. My code is not working:

var detailGrid = $("#grid-details").kendoGrid({
            detailTemplate: getDetailTemplate,
            detailInit:InitFunc,
            detailCollapse: function (e) {
                if (.....here I check for changes ) {
                e.preventDefault();
                return false;

                }
            },​

......});

I got to e.preventDefault(), but the row is collapsed anyway

Boyan Dimitrov
Telerik team
 answered on 16 Oct 2015
2 answers
263 views

I was wondering how to hide/show columns based on  the values of aggregate values in footer. For example:

  @(Html.Kendo().Grid<Payroll.Models.PayrollAuthorizationByDepartmentModel>()
.Name("Grid")

.Columns(columns =>
{
columns.Bound(dataSource => dataSource.EmployeeId).Title("Emp. No");
columns.Bound(dataSource => dataSource.EmployeeNameForDisplay).Title("Emp. Name");
columns.Bound(e => e.RegHours).Title("Reg.")
.ClientFooterTemplate("<div style='text-align: right'> \\#= kendo.toString(sum, '0.00')\\# </div>")
.ClientTemplate("\\#= kendo.toString(RegHours, '0.00')\\#");
columns.Bound(e => e.OTHours).Title("OverTime 1.5")
.ClientFooterTemplate("<div style='text-align: right'> \\#= kendo.toString(sum, '0.00')\\# </div>")
.ClientTemplate("\\#= (OTHours==0)? '':kendo.toString(OTHours, '0.00')\\#");                        
                        })
.DataSource(dataSource => dataSource
.Ajax()
.Aggregates(aggregates =>
{
aggregates.Add(e => e.RegHours).Sum();
aggregates.Add(e => e.OTHours).Sum();                                                              
                                                          })
.Read(read => read.Action("AuthorizationByEmployee_Read", "Authorize", new { locationId = @ViewBag.LocationId, departmentId = "#=DepartmentId#", startDate = @ViewBag.StartDate, endDate = @ViewBag.EndDate }))
.ServerOperation(false)
.Sort(sort => sort.Add("EmployeeFirstName").Ascending())
)
.Sortable()
.Events(events => events.DataBound("onDataBoundOfChildGrid"))
.ToClientTemplate()
)

 

How to hide the column if the sum is 0?

 

Thanks!

Stephen
Top achievements
Rank 1
 answered on 15 Oct 2015
3 answers
136 views

I am having some trouble with a simple bar chart.

Here is my model

public class PrivateReportCardCumulativeInvestments
{
    public int FUND_INT { get; set; }
    public int YearCategory { get; set; }
    public decimal Commitments { get; set; }
    public decimal Distributions { get; set; }
    public decimal Draw_Down { get; set; }
    public decimal Fees { get; set; }
 
    public PrivateReportCardCumulativeInvestments()
    {
    }
}

 

And here is my Chart.

    @(Html.Kendo().Chart<BetaSMTRApp.Business.PrivateReportCardCumulativeInvestments>()
                                .Name("ChartInvestmentCumulations_" + item.FUND_INT.ToString())
                                .Title("Cumulative Investments")
                                .DataSource(dataSource => dataSource
                                                .Read(read => read.Action("GetCumulativeInvestments", "PrivateReportCard", new { fundInt = item.FUND_INT }))
                                              )
 
                                .Series(series =>
                                {
                                    series.Column(model => model.Commitments).Name("Commitments");
                                    series.Column(model => model.Distributions).Name("Distributions");
                                    series.Column(model => model.Draw_Down).Name("DrawDowns");
                                    series.Column(model => model.Fees).Name("Fees");
                                })
                                .Legend(legend => legend
                                    .Position(ChartLegendPosition.Bottom)
                                )
                                .ValueAxis(axis => axis.Numeric()
                                    .Labels(labels => labels
                                        .Format("${0}")
                                        .Skip(2)
                                        .Step(2)
                                    )
                                )
                                .CategoryAxis(axis => axis
                                    .Categories(model => model.YearCategory)
                                    .Labels(labels => labels.Format("yyyy"))
                                )
)

Looking for the following result

 

Vertical Axis (value of the following)... model.Commitments, model.Distributions, model.DrawDown, Model.Fees (values are between 0 and 3 as a decimal with 1 precision.

Horizontal Axis (model.YearCategory)

Bars -- Commitment, Distribution, DrawDown and Fees.

Example of data

YearCategory    Commitments Distributions   Draw_Down   Fees
2004    71.5    36.5    0   0.5
2005    35.8    50.6    6.4 2
2006    0   90.9    28  4
2007    0   111.7   43.2    5.7
2008    0   110.4   50.5    8.1
2009    0   113 59.3    9.8
2010    0   113.7   81.2    11.2
2011    0   111 88.3    12.7
2012    0   74.6    146.4   14
2013    0   76.5    153.6   15.1
2014    0   41.9    252 16.3

Any ideas of what i am missing?

Thanks

Corey

Paul
Top achievements
Rank 1
 answered on 15 Oct 2015
15 answers
3.0K+ views

I want to open a kendo window when click in kendo grid cell. The code is

                columns.Bound(s => s.HasComments)
                    .HeaderHtmlAttributes(new { title = "Comments"})
                    .ClientTemplate("<div class='sprite sprite-note' onclick='openCommentWindow('ResourceSport', '<#= ResourceSportId #>', '<#= SportName #>', '" + Model.Editable + "', 'true');'></div>")
                    .Width(100);

openCommentWindow is jquery function. But onclick does not respond at all. I want to know what is the problem and how to do this. Thanks.

Dimiter Madjarov
Telerik team
 answered on 15 Oct 2015
5 answers
1.4K+ views
I have a nested grid that when I am adding a new child, I would like  the input for the new child to be filled based on a column from the parent.
Basically I need to get reference to the data object for the parent of the child. I am not sure how to traverse the node structure to go all the way to the parent and get a column. (2 input columns and a mulltiselect column),

the edit event has the following according to the docs

http://docs.kendoui.com/api/web/grid#events-edit
Alexander Popov
Telerik team
 answered on 15 Oct 2015
1 answer
1.9K+ views

Hi!
I would like to say that i have already read similiar topics in this forum and none of them solved my problem. When im trying to access dynamically created window data("kendoWindow") the result is undefined :/

So i've got a "Contractors" View which got almost nothing inside it, besides kendo Grid and few buttons + this placeholder:

<div id="editContractorNaturalPersonWindow"></div>

When a user clicks the button, window is opened:

 

$(".contractorNaturalPerson").click(function () {
                var dataUrl = $(this).data("url");
                $("#editContractorNaturalPersonWindow").kendoWindow({
                    content: {
                        title: "title123",
                        url: dataUrl
                    },
                    open: function () {
                        kendoWindow_center("#editContractorNaturalPersonWindow");
                    },
                    refresh: function () {
                        kendoWindow_center("#editContractorNaturalPersonWindow");
                    }
                });
                var dialog = $("#editContractorNaturalPersonWindow").data("kendoWindow");
                dialog.open();
            });

 

Till now everything works, window is being opened, centered, etc. Inside dynamically loaded "EditContractorNaturalPerson" Partial View i've got a simple form with few textboxes and this script:

 

$('.editContractorNaturalPersonForm').submit(function () {
            if ($(this).valid()) {
                $.ajax({
                    url: this.action,
                    type: this.method,
                    data: $(this).serialize(),
                    success: function (data) {
                        if (data.result == "Success") {
                            debugger;
                            var dialog = $("#editContractorNaturalPersonWindow").data("kendoWindow");
                            dialog.close();
                            
                            $('#contractorsGrid').data('kendoGrid').dataSource.read();
                            return false;
                        }
                        else if (data.result == "Error") {
                            debugger;
                            for (prop in data.modelErrors) {
                                if (data.modelErrors[prop].length > 0) {
 
                                    $("#" + prop).next().text(data.modelErrors[prop]);
                                }
                            }
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert("EditContractorNaturalPerson-AjaxError");
                    }
                });
            }
            return false;
        });

 

This line:

var dialog = $("#editContractorNaturalPersonWindow").data("kendoWindow");

Gives me undefined, EVEN THAT jQuery found this object:

$("#editContractorNaturalPersonWindow")

 I already tried to remove window by destroying this jquery object (k-window) but it breaks its functionality. What can i do ? Please help :)

Plamen Lazarov
Telerik team
 answered on 15 Oct 2015
3 answers
491 views

Hi,

 I have probably missed something really obvious, but I just can't seem to find the right property.

 I have a Grid bound to an OData source from which I am auto generating the columns. When this happens the column titles are not split around capital letters so they are readable unlike when they are bound individually. I tried using a column build action to set the titles of the columns, but it doesn't seem to work... unless I am doing something not quite right.

 A bit of example code here (I have just tried to change the column name to a set value, but it doesnt work when I try to split the column member name either)

@(Html.Kendo().Grid<dynamic>()
      .Name(Model.Name)
      .Columns(columns =>
      {
          //columns.AutoGenerate(true);
          //columns.AutoGenerate(col => col.Title = col.Member.SplitPascalCase());
          columns.AutoGenerate(col => col.Title = "COLUMN NAME");
      })
      .DataSource(dataSource => dataSource
          .Custom()
          .Type("odata")
          .Schema(schema =>
          {
          schema.Data("value")
              .Total
              (
                    @<text>
                        function total(data)
                        {
                        return data["odata.count"];
                        }
                    </text>
                );
          })
          .Transport(transport =>
          {
              transport.Read(read => read.Url(Model.ODataPath).DataType("json"));
          }
          )
          .PageSize(Model.PageSize)
          .ServerPaging(true)
          .ServerSorting(true)
          .ServerFiltering(true)
      )

thanks,

 Rob

Nikolay Rusev
Telerik team
 answered on 15 Oct 2015
4 answers
375 views

Hello,

 

We are updating a project to the most recent release (2015.3.930), pretty much specifically to fix the whole "No records found" scenario.  Currently we use the javascript method people have come up with, putting a setTimeout on the DataBound event of the grid, but this is pretty unreliable and as such, when the official No Records Found came out, we would prefer to use that.

 

It seems however that in our most unreliable case (a nested grid, 5 levels down, business requirement), the now-built-in NoRecords is not working at all.  It works fine on single level grids, but in this instance, when the grid is a Client Template (using .ToClientTemplate() - we use the fluent API for MVC), it doesn't do anything.

 

I thought maybe it was because we had Pageable disabled (.Pageable(paging => paging.Enabled(false))) and so there was no footer, but even enabling this didn't make it work.  The footer correctly detects that there are no items found (as it displays that default message in the bottom right corner), but the .NoRecords("No Records Found!") does not render in the grid, or in the DOM at all.

 

The below is what gets rendered, which has no message for the no records found.

 

<table role="grid">
<colgroup>
<col style="width: 22%;">
<col style="width: 21%;">
<col style="width: 40%;">
<col style="width: 10%;">
</colgroup>
<thead class="k-grid-header" role="rowgroup">
<tr role="row">
...
</tr>
</thead>
<tbody role="rowgroup">
<tr class="k-no-data">
<td colspan="4">
</td>
</tr>
</tbody>
</table>

 

 The definition of the subgrid is as follows

 

<script id="SuperSubGridTemplate" type="text/kendo-tmpl">    
        @(Html.Kendo().Grid<ReportSuperSubGridVM>()
              .Name("SuperSubGrid")
              .Columns(column =>
              {
                  column.Bound(x => x.Column1).Width("22%").Title(@Resources.Global.Column1);
                  column.Bound(x => x.Column2).Width("21%").Title(@Resources.Global.Column2);
                  column.Bound(x => x.Column3).Width("40%").Title(@Resources.Global.Column3);
                  column.Bound(x => x.Column4)
                      .ClientTemplate("\\#if(Column4){\\# " + @Resources.Global.Yes + "\\#}else{\\#" + @Resources.Global.No + "\\#}\\#")
                      .Width("10%")
                      .Title(@Resources.Global.Column4);
              })

              .DataSource(dataBinding => dataBinding
                  .Ajax()
                  .PageSize(500)
                  .Read(read => read.Action("GetSuperSubGridData", Constants.Controller_Report, new
                  {
                      Parameter1 = "#=ParentColumn1#"
                      ,Parameter2 = "#=ParentColumn2#"
                      ,Parameter3 = "#=ParentColumn3#"
                      ,Parameter4 = "#=ParentColumn4#"
                      ,Parameter5 = "#=ParentColumn5#"
                      ,Parameter6 = "#=ParentColumn6#"
                      ,Parameter7 = "#=ParentColumn7#"
                      ,Parameter8 = "#=ParentColumn8#"
                      ,Parameter9 = "#=ParentColumn9#"
                      ,Parameter10 = "#=ParentColumn10#"
                  }))
                   .Sort(c => c.Add(x => x.Column1))
              )              
              .Scrollable(scrolling => scrolling.Enabled(false))
              .Sortable()
              .Filterable(filtering => filtering.Enabled(true))
              .Pageable(paging => paging.Enabled(false))
              .NoRecords(@Resources.Global.NoResultsFound)
              .ToClientTemplate()
 )
</script>

  

Again, this works on non-nested grids, but for some reason I can't seem to get it to work on this one.

 

Thank you for any help!

CHRISTOPHER
Top achievements
Rank 1
 answered on 14 Oct 2015
1 answer
150 views

Hello,
I have a problem with a client detail template with a grid. If Kendo is localized into Czech can not open the detail view. Commented <globalization culture = "cs-Cz" uiCulture = "cs-CZ" /> in the web.config file to fix the problem.
I attach a simple project on which it is seen.

I delete kendo scripts and css from project.

Rosen
Telerik team
 answered on 14 Oct 2015
4 answers
343 views

We have a DropDownList that has several thousand records, so we set it up using Virtual following the example of the Virtualization demo.  We have a new requirement that those records need to be filtered by the selection of a different DropDownList, so this virtual DropDownList will need to cascade from the other DropDownList.  Even filtered, there will still be a thousand records in the DropDownList, so it still needs to be virtual.

Is it possible to use virtualization with a DropDownList that cascades?

Kevin
Top achievements
Rank 1
 answered on 13 Oct 2015
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
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?