Telerik Forums
Kendo UI for jQuery Forum
1 answer
760 views

I have create a kendo grid with batch editing using https://demos.telerik.com/kendo-ui/grid/editing for reference (using your demo service as suggested for my controller: https://github.com/telerik/kendo-ui-demos-service/blob/master/demos-and-odata-v3/KendoCRUDService/Controllers/ProductsController.cs).

The grid will read the data fine, but when I go to create the controller is unable to deserialize the "models" passed to it (as detailed in the parameterMaps function). After reading through various Telerik threads, I have tried ensuring editing mode is set to "incell" and ensuring batch mode is set to true. 

Do you know what I'm doing wrong that's stopping the data from binding?

 

Kendo grid

<div id="grid"></div>
 
  <script>
      $(document).ready(function () {
          var crudServiceBaseUrl = "/RegulationIndex",
              dataSource = new kendo.data.DataSource({
                  batch: true,
                  transport: {
                      read: {
                          url: crudServiceBaseUrl + "/GetRegulations",
                          dataType: "json",
                          type: "GET"
                      },
                      update: {
                          url: crudServiceBaseUrl + "/UpdateRegulations",
                          dataType: "json",
                          type: "PUT"
                      },
                      destroy: {
                          url: crudServiceBaseUrl + "/DeleteRegulations",
                          dataType: "json",
                          type: "DELETE"
                      },
                      create: {
                          url: crudServiceBaseUrl + "/AddRegulations",
                          dataType: "json",
                          type: "POST"
                      },
                      parameterMap: function (options, operation) {
                          if (operation !== "read" && options.models) {
                              return { models: kendo.stringify(options.models) };
                          }
                      }
                  },
                  pageSize: 20,
                  schema: {
                      model: {
                          id: "Id",
                          fields: {
                              Id: { editable: false },
                              LastReviewedDate: { editable: false },
                              LastReviewedBy: { editable: false }
                          }
                      }
                  }
              });
 
          $("#grid").kendoGrid({
              dataSource: dataSource,
              navigatable: true,
              pageable: true,
              height: 550,
              toolbar: ["create", "save", "cancel"],
              columns: [
                  { field: "Continent", width: 120 },
                  { field: "Area", width: 120 },
                  { field: "Country", width: 120 },
                  { field: "Service", width: 120 },
                  { field: "B2BOrB2C", title: "Customer Type", width: 120 },
                  { field: "RegulationName", title: "Regulation Name", width: 120 },
                  { field: "LastReviewedDate", format: "{0:dd/MM/yyyy}", width: 100 },
                  { field: "LastReviewedBy", width: 100 },
                  { command: "destroy", title: " ", width: 150 }],
              editable: "incell"
          });
      });
 
      function customBoolEditor(container, options) {
          $('<input class="k-checkbox" type="checkbox" name="Discontinued" data-type="boolean" data-bind="checked:Discontinued">').appendTo(container);
      }
  </script>

 

 

Controller action

        [HttpPost]
        [ProducesResponseType(StatusCodes.Status400BadRequest)]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        public async Task<IActionResult> AddRegulations()
        {
            var logMessage = new LogMessageFactory(this.GetType().Name, MethodBase.GetCurrentMethod().DeclaringType)
                .LogMessage;
            try
            {
                var body = JsonConvert.DeserializeObject<IEnumerable<RegulationViewModel>>("models");
                var gridRegulations = new List<RegulationViewModel>();
 
                if (body != null)
                {
                    if (!ModelState.IsValid)
                    {
                        return BadRequest(ModelState);
                    }
                    else
                    {
                        foreach (var reg in body)
                        {
                            RecordUserDateForRecordChange(reg);
                            var regulation = await _webApiClientSession.RegulationsWebApiClient.CreateRegulationAsync(reg);
                            var regulationViewModel = _mapper.Map<Regulation, RegulationViewModel>(regulation);
                            gridRegulations.Add(regulationViewModel);
                        }
                        _logger.LogDebug(logMessage);
                        return Json(gridRegulations);
                    }
                }
                else
                {
                    _logger.LogDebug(logMessage + "Failed to " + ControllerContext.HttpContext.Request.Method);
                    return BadRequest();
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, logMessage);
                return NotFound();
            }
        }
 

 

Nikolay
Telerik team
 answered on 18 May 2020
3 answers
234 views

Is there a way to programmatically initiate the built in grid search functionality from outside the grid?

I am working on updating a couple of old sites from before kendo had built in search functionality.  I built my own search function and added a text box outside of the grid for the user to search all of the columns.  I would like to switch from my custom search code to the built in grid search, but i need to leave the search ui the same.  

 

TIA,

Logan

Ivan Danchev
Telerik team
 answered on 18 May 2020
3 answers
112 views

Hi,

With PivotGrid is it possible to view the underlying data that makes up a calculated value. For example clicking on a cell and seeing all the rows that make up the calculated value for that cell.

Cheers,

Angel Petrov
Telerik team
 answered on 18 May 2020
2 answers
153 views

{ field: "LastName", label: "LastName:", validation: { required: true, message: "test" }, hint: "Hint: enter alphanumeric characters only." },

The validation attribute message seems to be wrong

It should be validationMessage not message

Michael
Top achievements
Rank 1
Veteran
 answered on 18 May 2020
2 answers
676 views
Can you use a textarea element as items.editor or make a TextBox multi-line
Michael
Top achievements
Rank 1
Veteran
 answered on 18 May 2020
5 answers
398 views

Hi team,

As the question says, Im trying to define my template content as part of an html data attribute, see dojo: https://dojo.telerik.com/UxAPOXeV

But i get a syntax error when the widget is initialized.

Please advise.

Thanks,
Grant

Tsvetomir
Telerik team
 answered on 15 May 2020
2 answers
257 views

Below is the kendo ui nested grid sample code and I highlighted the code which is the issue. Here I am trying to reference the nested grid inside a parent grid, but getting undefined exception. Not sure what I am doing wrong here.

var filterWorkOrderBundleDetails = function (DetailId) {
        var control = $("#grid_" + DetailId).data("kendoGrid");                                                              //(undefined): Not able to reference nested grid.
        //Todo

        return {            
            WorkOrderDetailId: DetailId
        }
    }

 

@(Html.Kendo().Grid<PM.Entities.Model.sp_Sel_WorkOrderDetailByWorkOrderNo_Result>()
    .Name("WorkOrderDetailGrid")
    .Columns(columns =>
    {
        columns.Bound(p => p.WorkOrderDetailNo).Title("Order Detail No").Filterable(e => e.Extra(false)).Width(80);
        columns.Bound(p => p.Description1).Title(productColumnTitle).Filterable(e => e.Extra(false)).Width(200);
        columns.Bound(p => p.AccountDetails).Title("Account").Filterable(e => e.Extra(false)).Width(200);
        columns.Bound(p => p.UnitPriceMultiplier).Title("Unit Price").Filterable(e => e.Extra(true)).Width(100).ClientTemplate("$#:kendo.toString(UnitPriceMultiplier, '" + @decimalFormat + "')#");
        columns.Bound(p => p.PartnerShare).Title("Partner Share").Filterable(e => e.Extra(true)).Width(100);
        columns.Bound(p => p.TelcoShare).Title(userSession.TenantName + " Share").Filterable(e => e.Extra(true)).Width(100);
        columns.Bound(p => p.Discount).Title("Adjustment").Filterable(e => e.Extra(true)).Width(100);
        columns.Bound(p => p.Description).Title("Description").Filterable(e => e.Extra(true)).Width(200);
    })
    .ClientDetailTemplateId("rowDetailTemplate")
    .DataSource(ds => ds
        .Ajax()
        .Read(read => read.Action("GetAppWorkOrderDetails1", "WorkOrder").Data("window.pm.order.tracking.filterWorkOrderDetails"))
        .PageSize(PageSize)
    )
    .NoRecords(NoRecordFound)
    .AutoBind(true)
    .Events(e => e.DataBound("window.pm.order.tracking.onDataBound"))
    .Pageable(page => page.PageSizes(PageSizes).Messages(msg => msg.Display("{0} - {1} of {2:n0} items")))
    .Scrollable(a => a.Height("auto"))
    .Sortable(s => s.SortMode(GridSortMode.MultipleColumn))
    .Resizable(e => e.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    )
</div>

<script id="rowDetailTemplate" type="text/x-kendo-template">
    #if (WorkOrderDetailId != null){#
    @(Html.Kendo().Grid<PM.Entities.Model.sp_Sel_WorkOrderDetailByWorkOrderNo_BundleItems_Result>()
        .Name("grid_#=WorkOrderDetailId#")
        .Columns(columns =>
        {
            columns.Bound(o => o.WorkOrderNo).Title("Order").Width(80);
            columns.Bound(o => o.WorkOrderDetailNo).Title("Order Detail No").Width(80);
            columns.Bound(o => o.Partner).Title("Partner").Width(120);
            columns.Bound(o => o.BillChargeCode).Title("Charge Code").Width(80);
            columns.Bound(o => o.AccountDetails).Title("Account").Width(120);
            columns.Bound(p => p.UnitPriceMultiplier).Title("Unit Price").Filterable(e => e.Extra(true)).Width(100).ClientTemplate("$\\\\#:kendo.toString(UnitPriceMultiplier, '" + @decimalFormat + "')\\\\#");
            columns.Bound(p => p.Quantity).Title("Quantity").Filterable(e => e.Extra(true)).Width(100);
            columns.Bound(p => p.PartnerShare).Title("Partner Share").Filterable(e => e.Extra(true)).Width(100);
            columns.Bound(p => p.TelcoShare).Title(userSession.TenantName + " Share").Filterable(e => e.Extra(true)).Width(100);
            columns.Bound(p => p.Discount).Title("Adjustment").Filterable(e => e.Extra(true)).Width(100);
            columns.Bound(o => o.Description).Title("Description").Width(120);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(PageSize)
            .Read(read => read.Action("GetAppWorkOrderBundleDetails", "WorkOrder").Data("window.pm.order.tracking.filterWorkOrderBundleDetails('#=WorkOrderDetailId#')"))
        )
        .Pageable()
        .Scrollable(a => a.Height("auto"))
        .Sortable(s => s.SortMode(GridSortMode.MultipleColumn))
        .Resizable(e => e.Columns(true))
        .Reorderable(reorder => reorder.Columns(true))
        .ToClientTemplate()
    )
    #}else{  }#
</script>

 

Please help me!

Anton Mironov
Telerik team
 answered on 15 May 2020
3 answers
239 views

I'm trying to put a context menu on a treeview. Which is working.But when I use the same code to target another css class (targeting <a> tags it's only showing the first letters of each word)

 

 

 

mudi
Top achievements
Rank 1
Veteran
 answered on 15 May 2020
9 answers
339 views

Hello,

I tried to add/edit data in dynamically added grids of a main grid. See code below.  When I added a new record in sub grid, the selected row in parent grid was collapsed and the first row was expanded. You can see screen captures in attached pdf file. 

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.css">
    <link rel="stylesheet" href="/_content/Plat.Core.UI.RazorComponent//Lib/Kendo/css/kendo.common-bootstrap.min.css">
    <link rel="stylesheet" href="/_content/Plat.Core.UI.RazorComponent//lib/kendo/css/kendo.bootstrap.min.css">
    <script src="/_content/Plat.Core.UI.RazorComponent/Lib/jquery/jquery-3.3.1.js"></script>
    <script src="/_content/Plat.Core.UI.RazorComponent/Lib/jquery/jquery-migrate-3.0.1.min.js"></script>
    <script src="/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="/Lib/KendoNew/js/kendo.all.min.js"></script>
    
    <title></title>
    
</head>
<body>
    <div id="divMain">
       <div id="dsgrid" class="grid"
                             data-role="grid"
                             data-sortable="true"
                             data-toolbar="['create']"
                             data-detail-init="viewModel.dsgrid_detailInit"
                             data-bind="source: dsSource, events: { dataBound: ds_dataBound }"
                             data-editable='{"mode": "popup" }'
                             data-columns='[
                                 {"field":"Name","title":"Name"},
                                 {"field":"Title","title":"Title"},
                                 {"command": [ "edit", "destroy" ], "filterable": false, "sortable": false, "width:": "240px"}
                                 ]'
                             data-detail-template='dssubgrid'
                             data-scrollable="false">

        </div>
    </div>

    <script>
        
        var viewModel;
        $(document).ready(function () {
            var reobj = {};
            reobj.Sources = [];

            viewModel = kendo.observable({
                dsSource: new kendo.data.DataSource({
                    data: reobj.Sources,
                    schema: {
                        model: {
                            id: "Name",
                            fields: {
                                Name: { validation: { required: true } },
                                Title: { validation: { required: true } },
                                TableName: { editable: true },
                                GetDataUrl: { editable: true },
                                TextField: { editable: true },
                                ValueField: { editable: true }
                            }
                        }
                    }
                }),

                dsgrid_detailInit: function (e) {
                    if (!e.data.Values) e.data.Values = [];
                    var ds = new kendo.data.DataSource({
                        data: e.data.Values,
                        schema: {
                            model: {
                                id: "Text",
                                fields: {
                                    Text: { editable: true, validation: { required: true } },
                                    Value: { editable: true, validation: { required: true } }
                                }
                            }
                        }
                    });
                    e.detailRow.find(".grid").kendoGrid({
                        dataSource: ds,
                        editable: "popup",
                        toolbar: ['create'],
                        columns: [{
                            title: "Value",
                            field: "Value"
                        }, {
                            title: "Text",
                            field: "Text"
                        }, {
                            command: ["edit", "destroy"]
                        }
                        ]
                    });
                },


                ds_dataBound: function (e) {
                    e.sender.expandRow(e.sender.tbody.find("tr.k-master-row").first());
                },


            });

            kendo.bind($("#divMain"), viewModel);
        });

    </script>
    <script id="dssubgrid" type="text/x-kendo-template">
        <div class='grid'></div>
    </script>
  </body>
</html>

How can I solve this issue?

Thanks

Lei

 

 

 

Lei
Top achievements
Rank 1
 answered on 14 May 2020
1 answer
190 views
I have a scheduler and my users are asking to be able to copy and paste the text in the events via mouse highlight, right-click, copy, but the scheduler does not allow this.  I have added a popup view for them and a button that copies all the text in the event to the clipboard, but they still want to be able to copy-paste just portions of the event text.  Is there a way to make the text selectable/highlight-able?
Martin
Telerik team
 answered on 14 May 2020
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
Map
Drag and Drop
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
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?