Telerik Forums
UI for ASP.NET MVC Forum
6 answers
3.4K+ views
Hi!

Is there any way to add dynamic default values? When I push the "Add row" button a new row with a new default value (max  value + 1) for count column should be added.

Example:

.ToolBar(toolbar => {
        toolbar.Create().Text("Add row");
    })
...
 .Model(model => {
            model.Id(n => n.ID);
            model.Field(c => c.count).DefaultValue(<this value needs to be max value + 1>);
            model.Field(c => c.count).Editable(false);
        })

I have tried to adding an event on .Events( e => e.Change("MyFunction"))  but the row adding is done after MyFunction event is fired.

/Malte

Randy
Top achievements
Rank 1
 answered on 24 Mar 2017
6 answers
1.0K+ views

How to customise row and column header in kendo spreadsheet 
Is there any Cell/Row template is available for kendo spreadsheet

Support for Item edit template

Support for different edit controls for different types of columns/rows

ullas
Top achievements
Rank 1
 answered on 24 Mar 2017
3 answers
603 views
I have a grid that display details of some items.  The grid has a custom command to open a window to display sub details of the selected item.  The grid that is displayed in the window that opens has inline editing turned on.  When I try to perform an update / create / delete, the Action is properly called, but the passed in model is null.
@(Html.Kendo().Grid<Carrier>()
      .Name("grid")
      .Columns(columns =>
          {
              columns.Bound(p => p.Name).Groupable(false).Width(125);
              columns.Bound(p => p.AuthorityReceived)
                     .Title("A")
                     .Filterable(false)
                     .Width(40)
                     .ClientTemplate("<input type='checkbox' disabled='disabled' #= AuthorityReceived ? checked='checked':'' # />");
              columns.Bound(p => p.W9Received)
                     .Title("W9")
                     .Filterable(false)
                     .Width(40)
                     .ClientTemplate("<input type='checkbox' disabled='disabled' #= W9Received ? checked='checked':'' # />");
              columns.Bound(p => p.InsuranceReceived)
                     .Title("Ins")
                     .Filterable(false)
                     .Width(40)
                     .ClientTemplate("<input type='checkbox' disabled='disabled' #= InsuranceReceived ? checked='checked':'' # />");
              columns.Bound(p => p.Phone1).Groupable(false).Title("Phone 1").Width(125);
              columns.Bound(p => p.Phone2).Groupable(false).Title("Phone 2").Width(125);
              columns.Bound(p => p.AfterHoursPhone).Groupable(false).Title("After Hrs #").Width(125);
              columns.Bound(p => p.Email).Groupable(false).Width(125);
              columns.Command(command => command.Custom("ViewComments").Click("showComments"));
          })
      .Groupable()
      .Pageable()
      .Sortable()
      .Scrollable()
      .Filterable()
      .Selectable()
      .Resizable(resize => resize.Columns(true))
      .Reorderable(reorder => reorder.Columns(true))
      .DataSource(
          dataSource => dataSource
                            .Ajax()
                            .PageSize(50)
                            .Read(read => read.Action("CarrierRead", "DataActions")))
      )
 
@(Html.Kendo().Window().Name("Comments")
      .Title("Comments")
      .Visible(false)
      .Modal(true)
      .Draggable(true)
      .Resizable()
      )
 
<script id="comments-template" type="text/x-kendo-template">
    <div id="details-container">
        <h3>#= Name #</h2>
    @(Html.Kendo().Grid<CarrierComment>()
          .Name("grid_#=CarrierId#")
          .Columns(columns =>
              {
                  columns.Bound(o => o.Comment);
                  columns.Bound(o => o.AddedBy).Width(150);
                  columns.Bound(o => o.TimeStamp).Format("{0:MM/dd/yyyy hh:mm tt}").Width(175);
                  columns.Command(command =>
                      {
                          command.Destroy();
                          command.Edit().UpdateText("Save");
                      }).Width(200);
              })
          .DataSource(
              dataSource =>
              dataSource
                  .Ajax()
                  .PageSize(5)
                  .Model(model => model.Id(p => p.CommentId))
                  .Create(update => update.Action("CommentCreate", "DataActions", new {carrierId = "#=CarrierId#"}))
                  .Update(update => update.Action("CommentUpdate", "DataActions"))
                  .Destroy(update => update.Action("CommentDelete", "DataActions"))
                  .Read(read => read.Action("CommentRead", "DataActions", new {carrierId = "#=CarrierId#"}))
          )
          .ToolBar(toolbar => toolbar.Create().Text("New Comment"))
          .Editable(editable => editable.Mode(GridEditMode.InLine))
          .Pageable()
          .Sortable()
          .Selectable()
          .Resizable(resize => resize.Columns(true))
          .Reorderable(reorder => reorder.Columns(true))
          .Scrollable()
          .ToClientTemplate())
    </div>
</script>
 
<script type="text/javascript">
    var detailsTemplate = kendo.template($("#comments-template").html());
 
    function showComments(e) {
        e.preventDefault();
 
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var wnd = $("#Comments").data("kendoWindow");
 
        wnd.content(detailsTemplate(dataItem));
        wnd.center().open();
    }
</script>
[HttpPost]
        public ActionResult CommentRead([DataSourceRequest] DataSourceRequest request, int carrierId)
        {
            try
            {
                var facade = new CarrierFacade();
                var comments = facade.GetAllComments(carrierId);
                return Json(comments.ToDataSourceResult(request));
            }
            catch (DbException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View("Error");
            }
        }
 
        [HttpPost]
        public ActionResult CommentCreate([DataSourceRequest] DataSourceRequest request, CarrierComment comment)
        {
            if (comment != null && ModelState.IsValid)
            {
                try
                {
                    var facade = new CarrierFacade();
                    facade.InsertComment(comment);
                }
                catch (DbException ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return View("Error");
                }
            }
 
            return Json(new[] {comment}.ToDataSourceResult(request, ModelState));
        }
 
        [HttpPost]
        public ActionResult CommentUpdate([DataSourceRequest] DataSourceRequest request, CarrierComment comment)
        {
            try
            {
                var facade = new CarrierFacade();
                facade.UpdateComment(comment);
                return Json(ModelState.ToDataSourceResult());
            }
            catch (DbException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View("Error");
            }
        }
 
        [HttpPost]
        public ActionResult CommentDelete([DataSourceRequest] DataSourceRequest request, CarrierComment comment)
        {
            try
            {
                var facade = new CarrierFacade();
                facade.DeleteComment(comment.CommentId);
                return Json(ModelState.ToDataSourceResult());
            }
            catch (DbException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View("Error");
            }
        }
If I move the Grid out of the window, the model that is passed to my Controller's actions is no longer null.  Any idea why this would be?
Rogerio
Top achievements
Rank 1
 answered on 23 Mar 2017
4 answers
72 views

My dialog has no buttons... Well not really, they're there but they're white.  White button, white text... They don;t show up until I hover over one of them.  What styles or classes do I need to edit to get my dialog buttons to show up?

 

Joe
Top achievements
Rank 1
 answered on 23 Mar 2017
5 answers
397 views

Hello,

If I use kendoValidator in a grid Editor template the error is shown in a tooltip over the field - if I use
a "normal" view the kendoValidator error is shown under the field (see attached Pictures)

  • how to have the same "Tooltip" error in a "normal" form the same as in the grid template?

robert

Viktor Tachev
Telerik team
 answered on 23 Mar 2017
1 answer
123 views
How to reproduce.

 

Have a Grid setup,

Use Template like this.

.Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("Example"))

Inside Example Template

Get something like this to the bottom of the page other than your normal input:

<script>
    $(document).ready(function () {
        setTimeout(function () {
            // comments that will cause problem
            if ($("#hideClassId").val() > 0) {
                $("#tClassId").hide();
                $("#tClass").show();
            }
        });
    });
 
    // comments that can cause problem
    $("input#IsActive").on('change', function () {
        $('#ActiveWaiting').prop('checked', false);
    });
 
    // comments that can cause problem
    $('#ActiveWaiting').on('change', function () {
        $("input#IsActive").prop('checked', false);
    });
</script>

 

Then the popup would freeze.
This is what the error would look like in the console.

Uncaught SyntaxError: Unexpected end of input
    at eval (<anonymous>)
    at Function.globalEval (https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js:2:2662)
    at n.fn.init.append (https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js:3:22791)
    at M.fn.init.n.fn.(anonymous function) [as appendTo] (https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js:3:24510)
    at init._createPopupEditor (https://kendo.cdn.telerik.com/2017.1.223/js/kendo.all.min.js:49:21766)
    at HTMLAnchorElement.<anonymous> (https://kendo.cdn.telerik.com/2017.1.223/js/kendo.all.min.js:49:27635)
Stefan
Telerik team
 answered on 23 Mar 2017
1 answer
191 views

I have table in database which contains events of a system and these events have severity code and event code. These codes have to be localized, it means the text for the severity and event codes should be taken from resource files.

Here is how we construct data for the grid:

public ActionResult GetEvents([DataSourceRequest] DataSourceRequest request)
{
    IQueryable<SystemEventGridModel> data = SystemEvent.GetSystemEventFromDatabase().Select(systemEvent =>
        new SystemEventGridModel
        {
            Id = systemEvent.Id,
            EventCode = systemEvent.EventCode,
            SeverityCode = systemEvent.SeverityCode,
            Date = systemEvent.Date,
            Node = systemEvent.Node,
            IsActive = systemEvent.IsActive
        });
 
    DataSourceResult dataSourceResult = data.ToDataSourceResult(request);
    foreach (SystemEventGridModel gridModel in dataSourceResult.Data)
    {
        gridModel.EventText = Language.ResourceManager.GetString($"EventText{gridModel.EventCode}");
        gridModel.SeverityText = Language.ResourceManager.GetString($"SeverityText{gridModel.SeverityCode}");
    }
    return Json(dataSourceResult);
}

 

Then in the grid we show the localized text but not the codes:

@(Html.Kendo().Grid<SystemEventGridModel>()
      .Name("SystemEventGrid")
      .Columns(columns =>
      {
          columns.Bound(x => x.Node).Title(Language.SystemEventGridModelTitleNode);
          columns.Bound(x => x.SeverityCode).Title(Language.SystemEventGridModelTitleSeverityText).ClientTemplate("#=SeverityText#").Filterable(x => x.Multi(true).CheckAll(false).ItemTemplate("function(e){return columnFirtalableItemTemplate('SeverityCode', 'SeverityText')}"));
          columns.Bound(x => x.EventCode).Title(Language.SystemEventGridModelTitleEventText).ClientTemplate("#=EventText#");
          columns.Bound(x => x.Date).Title(Language.SystemEventGridModelTitleDate);
          columns.Bound(x => x.IsActive).Title(Language.SystemEventGridModelTitleIsActive);
      })
      .DataSource(binding => binding.Ajax().Read("GetEvents", "Home", null))
      .Sortable()
      .Filterable()
      .Pageable(x => x.Refresh(true)))

 

The problem is that we can't use the standard filtering for the columns (e.g. EventText) which do not existing in database and are taken from different places:

http://imgur.com/a/bcV7i

Is there a way to apply the filtering for the text and search by code from database?

P.S. I attached only the source files (models, views and controllers) for the example code.

Konstantin Dikov
Telerik team
 answered on 23 Mar 2017
4 answers
1.1K+ views

I have a kendo grid which is defined as below

$('#BrowseSchool').kendoGrid({
  columns: [{
    title: 'Name',
    headerAttributes: { "data-field": 'Name', "data-title": 'Name' },
    field: 'Name',
    encoded: true
  }, {
    title: 'City',
    headerAttributes: { "data-field": 'City', "data-title": 'City' },
    field: 'City',
    encoded: true
  }, {
    title: 'State',
    headerAttributes: { "data-field": 'State', "data-title": 'State' },
    field: 'State',
    encoded: true
  }, {
    title: 'Zip',
    headerAttributes: { "data-field": 'Zip', "data-title": 'Zip' },
    field: 'Zip',
    encoded: true
  }],
  pageable: {
    buttonCount: 10
  },
  sortable: true,
  selectable: 'Single, Row',
  filterable: true,
  scrollable: {
    height: '200px'
  },
  messages: {
    noRecords: 'No records available.'
 
  },
  dataSource: {
    type: (function() {
      if (kendo.data.transports['aspnetmvc-ajax']) {
        return 'aspnetmvc-ajax';
      } else {
        throw new Error('The kendo.aspnetmvc.min.js script is not included.');
      }
    })(),
    transport: {
      read: {
        url: '/Student/Student_Read'
      },
      prefix: ''
    },
    pageSize: 10,
    page: 1,
    total: 0,
    serverPaging: true,
    serverSorting: true,
    serverFiltering: true,
    serverGrouping: true,
    serverAggregates: true,
    filter: [],
    schema: {
      data: 'Data',
      total: 'Total',
      errors: 'Errors',
      model: {
        fields: {
           Address1: { type: 'string' },
           Name:     { type: 'string' },
           City:     { type: 'string' },                                       
           State:    { type: 'string' },
           Zip:      { type: 'string' }
          }
        }
      }
    }
  }
});

 

I have a div tag defined as below in my view, where the grid is loaded.

<div id="BrowseSchool" class="browse"></div>

 

Now I want that if there are no records returned by the Kendo grid when a filter is applied, I want to hide my div inside which kendo grid loads and show a different div.
I have tried adding databound event to my grid like below:

databound: function (e) {
  alert("No Data");
  //var grid = $("#BrowseSchool").data("kendoGrid");
  //if (grid.dataSource.total() == 0) {
  //  alert("No Data");
  //  $("#BrowseSchool").hide();
  //}
},

 

But, this doesn't seem to be working, as I didn't get the alert box.
My question is, how can I hide a div if there are no records returned by the kendo grid when a filter is applied?

Thanks in advance!

Stefan
Telerik team
 answered on 23 Mar 2017
1 answer
3.6K+ views

Is there any classes I can add to a button to change the styling similar to bootstrap's "btn-danger"?

For buttons that do potentially dangerous things, I would like to add special styling to them but not have to worry about if the text color will be correct. Currently there is the "Primary" attribute, but it'd be great if there were other categories.

 

I understand adding features like that isn't easy to do quickly, but if there are any classes I can add to a normal kendo button to change color and style that's be great!

 

Ivan Danchev
Telerik team
 answered on 23 Mar 2017
1 answer
109 views

Hi All,

I need to display the filter criteria used by a user for a kendoUI grid. Is there any built in way to display this info?
If not, how can I access the those values (like value in search textbox, greater than, less than condition values etc).

Viktor Tachev
Telerik team
 answered on 22 Mar 2017
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
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
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
Bronze
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
Bronze
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?