Telerik Forums
Kendo UI for jQuery Forum
1 answer
454 views

I have multiple grids loading on a page. I want to hide the entire page until all grids are loaded. The grids are dynamically loaded based off of a table. 

 In a partial view I do this for each category:

 

<div id="@gridName" style="display:none;"></div>            
            <script type="text/javascript">
    $(document).ready(function() {
        $("#@gridName").kendoGrid({
            dataSource: new kendo.data.DataSource({
                schema: {
                    model: {
                        id: "CostSheetDetailId",
                        fields: {
                            CostSheetDetailId: { editable: false },
                            FriendlyName: { nullable: false, type: "string", defaultValue: "" },
                            EquipmentModelId: { editable: true, nullable: false},
                            Unit: { type: "number", editable: true, defaultValue: "0" },
                            Price: { type: "number", editable: true, defaultValue: "0" },
                            Budget: { type: "number", editable: true, defaultValue: "0" },
                            Actual: { type: "number" },
                            CostSheetCategoryId: {nullable: false, type: "number", defaultValue: @Model.Category.CostSheetCategoryId },
                            CostSheetId: { nullable: false, type: "number", defaultValue: @Model.CostSheetId },
                            Tooltip: { nullable: true, type: "string" }
                        }
                    },
                    errors: "errorMsg"
                },
                error: function (e) {
                    if(e.errors !== undefined ) {
                        toastr.options = {
                            "positionClass": "toast-bottom-full-width"
                        };
                        toastr.error('There is an error: ' + e.errors, 'Uh Oh!');
                    }

                    this.cancelChanges();
                },
                transport: {
                    read: {
                        url: "/CostSheet/CostSheetCategoryDetailGet",
                        dataType: "json",
                        data: {
                            Id: @Model.CostSheetId,
                            CostSheetCategoryId: "@Model.Category.CostSheetCategoryId",
                            IsFixed: "@Model.Category.IsFixed"
                                    }
                                },
                                create: {
                                    url: "/CostSheet/CostSheetCategoryDetailCreate",
                                    dataType: "json",
                                    type: "POST",
                                    data: {
                                        __RequestVerificationToken: getAntiForgeryToken()
                                    }
                                },
                                update: {
                                    url: "/CostSheet/CostSheetCategoryDetailEdit",
                                    dataType: "json",
                                    type: "POST",
                                    data: {
                                        __RequestVerificationToken: getAntiForgeryToken()
                                    }
                                },
                                destroy: {
                                    url: "/CostSheet/CostSheetCategoryDetailDelete",
                                    dataType: "json",
                                    type: "POST",
                                    data: {
                                        __RequestVerificationToken: getAntiForgeryToken()
                                    }
                                },
                                parameterMap: function (data, operation) {
                                    if (operation === "update") {
                                        data.CreateDate = _dateToString(data.CreateDate);
                                        data.LastModDate = _dateToString(data.LastModDate);
                                    }
                                    return data;
                                }
                            }
                        }),
                        toolbar: ["create"],
                        sortable: true,
                        columns: [
                            { field: "EquipmentModelId", title: "Name", template: "# if (Tooltip != null) { #" +
                                    "<span data-toggle=\"tooltip\" title=\"#=Tooltip#\">#=FriendlyName#</span>" +
                                "# } else { #" +
                                    "<span data-toggle=\"tooltip\" title=\"#=Tooltip#\">#=FriendlyName#</span>" +
                                "# } #", editor: equipmentModelDropDownEditor },
                            { field: "Unit", title: "Unit", width: "180px", editor: unitNumericEditor },
                            { field: "Price", title: "Price", width: "180px", editor: priceNumericEditor, format: "{0:c}" },
                            { field: "Budget", title: "Budget", width: "180px", editor: budgetStaticEditor, format: "{0:c}", },
                            { field: "Actual", title: "Actual", widht: "180px" },
                            { command: ["edit", "destroy"], title: "&nbsp;", width: "211px" }
                        ],
                        editable: "inline",
                        dataBound: function(e) {
                            $('#@gridName').slideDown("slow");
                        }
                    });
                });
            </script>

 

How do I keep the page blank until all of them have loaded?

Dimiter Madjarov
Telerik team
 answered on 14 May 2015
1 answer
344 views

So I implemented inline editing on my grid, and it all works fine and saves fine. The only problem is that when I click the edit button, my drop downs start off on Index 0 (which is blank) but I want them to start on the value that was on the grid initially. So for example if I had two Rate Types, "Regular", and "Discount", and suppose that my row's rate type is "Discount". When I click the edit button, I expect the Dropdown to be defaulted to "Discount" which was the row's initial value, but instead it is just a blank value at index 0. Please help! Here is the code :

 

Gird :

      @(Html.Kendo().Grid<CirculationDatabase.DAL.Publication>()
            .Name("PubGrid")

            .Columns(columns =>
            {
                
                columns.Bound(p => p.PubName).Title("Publication").Width("300px").HeaderHtmlAttributes(new { style = "font-size:13px;" });
            })
           
            .Pageable()
            .Sortable()
            .Scrollable()
            .ClientDetailTemplateId("template")
            .HtmlAttributes(new { style = "height:730px;" })
            
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Events(events => events.Error("error_handler"))
                .Model(model => model.Id(p => p.Publication_ID))
                .Create(update => update.Action("EditingPopup_Create", "Grid"))
                .Read(read => read.Action("ReturnPublicationInfo", "Publication"))
                .Update(update => update.Action("EditingPopup_Update", "Grid"))
                .Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
            )
            
            .Events(events => events.DataBound("dataBound"))
           
        )

            <script id="template" type="text/kendo-tmpl">
                 @(Html.Kendo().TabStrip()
            .Name("tabStrip_#=Publication_ID#")
            .SelectedIndex(0)
            .Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
            .Items(items =>
            {
                items.Add().Text("Domestic").Content(@<text>
             @(Html.Kendo().Grid<CirculationDatabase.DAL.proc_getPubGrid>()
                        .Name("subDomestic_#=Publication_ID#")
                        .Columns(columns =>
                        {
                            columns.Bound(x => x.PriceAmount).ClientTemplate("$" + "\\#=PriceAmount\\#");
                            columns.Bound(x => x.Rate).EditorTemplateName("rateEditor");
                            columns.Bound(x => x.DurationPeriod).Title("Duration (Months)").EditorTemplateName("durationEditor");
                            columns.Command(x => x.Edit());

                        })
                        
                           .Editable(editable => editable.Mode(GridEditMode.InLine))
                        
                        .DataSource(dataSource => dataSource
                            .Ajax()
                          
                            .PageSize(5)
                           .Events(events => 
                               {
                                   events.Error("error_handler");
                                       events.RequestEnd("onRequestEnd");
                                      
                               })
                .Model(model =>
                            {
                                model.Id(p => p.Price_ID);
                                model.Id(i => i.Duration_ID);
                                model.Field(i => i.DurationPeriod).DefaultValue(ViewData["DurationPeriod"] as CirculationDatabase.DAL.proc_getPubGrid);
                              
                            })
                .Create(update => update.Action("EditingPopup_Create", "Grid"))
                .Read(read => read.Action("ReturnPublicationInfoSubgrid", "Publication", new { pubID = "#=Publication_ID#", type = "Domestic" }))
                .Update(update => update.Action("UpdatePublicationInfo", "Publication").Data("dropDownValues"))
                .Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))

                                )
                        
                        .Pageable()
                        .Sortable()
                        .ToClientTemplate())
               </text>);

                items.Add().Text("Foreign").Content(@<text>
             @(Html.Kendo().Grid<CirculationDatabase.DAL.proc_getPubGrid>()
                        .Name("subForeign_#=Publication_ID#")
                        .Columns(columns =>
                        {
                            columns.Bound(x => x.PriceAmount).ClientTemplate("$" + "\\#=PriceAmount\\#");
                            columns.Bound(x => x.Rate).EditorTemplateName("rateEditor");
                            columns.Bound(x => x.DurationPeriod).Title("Duration (Months)").EditorTemplateName("durationEditor");
                            columns.Command(x => x.Edit());

                        })

                         .Editable(editable => editable.Mode(GridEditMode.InLine))

                        .DataSource(dataSource => dataSource
                            .Ajax()
                           .PageSize(5)
                           .Model(model =>
                                       {
                                           model.Id(i => i.Price_ID);
                                        
                                 })
                              
                           .Events(events => 
                               {
                                   events.Error("error_handler");
                                       events.RequestEnd("onRequestEnd");
                               })
                            .Create(update => update.Action("EditingPopup_Create", "Grid"))
                            .Read(read => read.Action("ReturnPublicationInfoSubgrid", "Publication", new { pubID = "#=Publication_ID#", type = "Foreign" }))
                            .Update(update => update.Action("UpdatePublicationInfo", "Publication").Data("dropDownValues"))
                            .Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
                                )
                        .Pageable()
                        .Sortable()
                        .ToClientTemplate())
               </text>);
                    
            }).ToClientTemplate())
              
                </script>

 

 Edit Template :

@model CirculationDatabase.DAL.proc_getPubGrid


    @(Html.Kendo().DropDownList()
    .Name("Rate") 
    .DataTextField("Rate") 
    .DataValueField("Rate_ID") 
   
    .DataSource(source =>
    {
        source.Custom()
              .ServerFiltering(true)
              
              .Type("aspnetmvc-ajax") //Set this type if you want to use DataSourceRequest and ToDataSourceResult instances
              .Transport(transport =>
              {
                  transport.Read("populateRateDDL", "Publication");
                  
              })
              .Schema(schema =>
              {
                  schema.Data("Data") //define the [data](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data) option
                        .Total("Total"); //define the [total](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total) option
              });
    })
)

 

Controller :

 

using CirculationDatabase.DAL;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;

namespace CirculationDatabase.Controllers
{
   

    public class PublicationController : Controller
    {
        private readonly EntitiesModel db = new EntitiesModel();
        public ActionResult Publications()
        {

            if (Request.IsAuthenticated)
            {
                return View();
            }
            else
            {
                return RedirectToAction("Login", "Login");
            }
        }

        public ActionResult ReturnPublicationInfo([DataSourceRequest] DataSourceRequest gridRequest)
        {


            IList<proc_getPubs> myViewModels = new List<proc_getPubs>();
           

                foreach (proc_getPubs pub in db.Proc_getPubs())
                {
                    myViewModels.Add(pub);
                }
            

            return Json(myViewModels.ToDataSourceResult(gridRequest), JsonRequestBehavior.AllowGet);
        }

        public ActionResult ReturnPublicationInfoSubgrid([DataSourceRequest] DataSourceRequest gridRequest, int pubID, string type)
        {


            IList<proc_getPubGrid> myViewModels = new List<proc_getPubGrid>();
           
                foreach (proc_getPubGrid pub in db.Proc_getPubGrid(pubID, type))
                {
                    myViewModels.Add(pub);
                }
          

            return Json(myViewModels.ToDataSourceResult(gridRequest), JsonRequestBehavior.AllowGet);
        }
        
        
        public ActionResult populateRateDDL([DataSourceRequest] DataSourceRequest dropDownRequest)
        {
            IList<RateType> myViewModels = new List<RateType>();
           
                foreach (RateType rate in db.ExecuteStoredProcedure<RateType>("proc_getRateType", null))
                {
                    RateType r = new RateType()
                    {
                        Rate_ID = rate.Rate_ID,
                        Rate = rate.Rate
                    };
                    myViewModels.Add(r);
                }
          

            return Json(myViewModels.ToDataSourceResult(dropDownRequest), JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public ActionResult populateDurationDDL([DataSourceRequest] DataSourceRequest dropDownRequest)
        {
            IList<Duration> myViewModels = new List<Duration>();

                foreach (Duration duration in db.ExecuteStoredProcedure<Duration>("proc_getDuration", null))
                {
                    Duration dur = new Duration()
                    {
                        Duration_ID = duration.Duration_ID,
                        DurationPeriod = duration.DurationPeriod
                    };
                    myViewModels.Add(dur);
                }
           
            
            return Json(myViewModels.ToDataSourceResult(dropDownRequest), JsonRequestBehavior.AllowGet);
        }

       [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult UpdatePublicationInfo([DataSourceRequest] DataSourceRequest request, Price newPrice, string durationValue, string rateValue)
        {
            if (ModelState.IsValid)
            {

                Price priceToUpdate = db.Prices.FirstOrDefault(s => s.Price_ID == newPrice.Price_ID);
                priceToUpdate.Duration_ID = Convert.ToInt32(durationValue);
                priceToUpdate.Rate_ID = Convert.ToInt32(rateValue);
                priceToUpdate.PriceAmount = newPrice.PriceAmount;
                db.SaveChanges();
            }
            
            return Json(new[] { newPrice }.ToDataSourceResult(request, ModelState));
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }

       
     
    }
}

 

Entity :

 public partial class proc_getPubGrid
{
private int _publication_ID;
public virtual int Publication_ID
{
get
{
return this._publication_ID;
}
set
{
this._publication_ID = value;
}
}

private string _pubName;
public virtual string PubName
{
get
{
return this._pubName;
}
set
{
this._pubName = value;
}
}

private decimal? _priceAmount;
public virtual decimal? PriceAmount
{
get
{
return this._priceAmount;
}
set
{
this._priceAmount = value;
}
}

private int? _durationPeriod;
public virtual int? DurationPeriod
{
get
{
return this._durationPeriod;
}
set
{
this._durationPeriod = value;
}
}

private string _rate;
public virtual string Rate
{
get
{
return this._rate;
}
set
{
this._rate = value;
}
}

private int? _duration_ID;
public virtual int? Duration_ID
{
get
{
return this._duration_ID;
}
set
{
this._duration_ID = value;
}
}

private int? _rate_ID;
public virtual int? Rate_ID
{
get
{
return this._rate_ID;
}
set
{
this._rate_ID = value;
}
}

private int? _price_ID;
public virtual int? Price_ID
{
get
{
return this._price_ID;
}
set
{
this._price_ID = value;
}
}

}



 

Alexander Popov
Telerik team
 answered on 14 May 2015
3 answers
352 views
Dear Sir,

I have an application that I am modenizing .
In the original web app clicking a button at the end of the row would taggle the details of the row.

Using the samples I Used the .ClientDetailTemplateId and I can show the details fine, this is done by clicking the arrows at the side of the grid.
Is there a way to add a custom command button to open the details and could the colum holding the arrows be hidden from sight?

Yours,

Ariel
Dimiter Madjarov
Telerik team
 answered on 14 May 2015
3 answers
875 views
Hi!

I would like to have the scheduler's buttons in another language, so I've tried to set up the culture using:

<script src="@Url.Content("~/js/cultures/kendo.culture.es-UY.min.js")" type="text/javascript"></script>

and then in the document ready: kendo.culture("es-UY");

This is working just for some of the texts, but It's not working for any of the buttons inside the scheduler, for example for the buttons, "Today", "Show full day" and so on.

Is there an easy way to translate all this? Is there any workaround?

Thanks in advance!
Vladimir Iliev
Telerik team
 answered on 14 May 2015
2 answers
265 views

Hi, 

I want to make expand arrow on grid just to expand child items not to select this row.

I was trying to attach to event "detailExpand" but there I can only clear selection which I don't want to happen. 

Lukasz
Top achievements
Rank 1
 answered on 14 May 2015
1 answer
150 views

When using the Kendo Grid with a virtual scroller I have noticed that when I roll the wheel on my Microsoft Mouse one click there is no action.  On the second click It will roll 4 rows.

Comparatively, in the Silverlight RadGrid View, the scroller moves 2 rows on each mouse click turn.

Is there a setting, in the Kendo grid to allow the mouse wheel to be more responsive?

Plamen Lazarov
Telerik team
 answered on 14 May 2015
3 answers
165 views

I want to apply [ChildActionOnly] attribute to the action method used by kendo ui grid DataSource as in 

.DataSource(dataSource => dataSource           
            .Ajax()
            .Read(read => read.Action("Read", "Conrtoller")) 

 

but when I apply [ChildActionOnly] to Read(), everytrhing stops working

Boyan Dimitrov
Telerik team
 answered on 14 May 2015
1 answer
418 views

Hi,

I'm struggling to get a combination between a stackes bar and line chart. I have seen the examples (http://demos.telerik.com/kendo-ui/bar-charts/multiple-axes) basicly this is what I need. The only problem that I have json datasource (from a webapi).

 

How can I accomplish this.

   

01.$("#chart").kendoChart({
02.          theme: "Bootstrap",
03.          dataSource: {
04.              transport: {
05.                  read: {
06.                      url: "/api/meters/GetIndividueleMeters/
07.                      dataType: "json",
08.                      method: "get"
09.                  }
10.              },
11.              group: {
12.                  field: "Naam",
13.                  dir: "asc"
14.              },
15.              sort: {
16.                  field: "Datum",
17.                  dir: "asc"
18.              },
19.              requestStart: function () {
20.                  kendo.ui.progress($("#loading"), true);
21.              },
22.              requestEnd: function () {
23.                  kendo.ui.progress($("#loading"), false);
24. 
25.              }
26.          },
27.          legend: {
28.              position: "bottom"
29.          },
30.          seriesDefaults: {
31.              type: "column",
32.              stack: true
33.          },
34.          series: [{
35.              field: "Waarde"
36.          },

> here is something needed I presume

 
    ],
37.          categoryAxis: {
38.              field: "DatumString",
39.              labels: {
40.                  rotation: -45
41.              }
42.          },
43.          tooltip: {
44.              visible: true,
45.              template: "#= value # / #= series.name #"
46.          },
47.          dataBound: function (e) {
48. 
49.              $(".Laadtekst").hide();
50. 
51.              if (this.dataSource.data().length == 0) {
52.                  $(".GeenGegevensTekst").show();
53.              }
54.              else {
55.                  $("#chart").show();
56.              }
57.          }
58.      });

Thanks

Iliana Dyankova
Telerik team
 answered on 14 May 2015
4 answers
1.0K+ views
Hello Telerik-Team,

we are using Kendo 2013.2.716 and have an application that is not interested in local timezones. Internally all dates are stored as UTC, but the time part should always be ignored.
- we have a grid and a datepicker with a custom format (yyyy-MM-dd) within this grid
- we have also implemented your guide: Using UTC time on both client and server sides

reading and displaying of the Dates works perfectly :)

Because of our custom date format we also needed to change the parametermap:
$(document).ready(function () {
    var grid = $("#Grid").data("kendoGrid"),
    mvcTransport = new kendo.data.transports["aspnetmvc-ajax"]();
    grid.dataSource.transport.parameterMap = function (options, type) {
        if (type === "update" || type === "create") {
            var d = new Date(options.Startdate);
            options.Startdate = kendo.toString(new Date(d), "yyyy-MM-dd");
        }
        return mvcTransport.parameterMap(options, type);
    };
});

For employees in Asia and EU it works perfectly, but for the US (Timezone: UTC-5) we now have the following situation:
- if the user edits a date, the date is correctly sent to the Server (if the user selects Jan 2nd, then 2014-01-02 00:00:00 is submitted to the Server) -> perfect.
- but immediately after the update the grid shows Jan 1st
- only after the user hits the browser's refresh button it loads the correct date from the Server and displays it (Jan 2nd)

If I modify the ParameterMap and add the time offset myself (e.g. options.Startdate = "2014-01-02T05:00:00.000-05:00"), then the grid immediately shows the correct date, but the value sent to the server is useless, because it's a DateTime with Type "local", but I do not have any information about the timezone. If I just ignore the time and only store the date part, then it might be correct for the US users, but will be wrong for the EU & Asians...

Thank you,
Rainer
T. Tsonev
Telerik team
 answered on 14 May 2015
8 answers
288 views
I am encountering a problem with ng-disabled in IE10 with Kendo UI buttons, combo boxes, drop down lists, date pickers, and numeric text boxes.

Everything works fine in IE11, Firefox, Chrome, and Safari, but IE10 doesn't seem to respond to changes in the models.

Is this a known problem and is there a work around?
Kiril Nikolov
Telerik team
 answered on 14 May 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Drag and Drop
Map
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?