Telerik Forums
Kendo UI for jQuery Forum
3 answers
418 views

Hello 

I checked the remove functions of the Upload Widget. As far as I understand: Any remove functionality reacts only on files "inside" the Upload widget. The widget itself is not persistent: You can upload files by the widget to get files into that list. You then can delete/remove them right away. After reload the page this file list is empty. The usual business case I know is: Customer do upload files on a day and want to delete it any other day or just later. I have such a case and create a unique ID for each uploaded file. I wonder if and how it is possible to use the Upload widget by sending this ID and triggering the removeURL handler. I've found some very old entries, one with trigger the remove event by "$(".k-delete").parent().click();" but nothing happens doing that. 

The most simple way would be to add a file to be deleted on that file list and then call the removeURL handler. 

Is there an easy way to do that or is it better to use a separate AJAX call?

Regards

Ivan Danchev
Telerik team
 answered on 26 Apr 2017
2 answers
764 views

I'm updating my dropdown's datasource by calling   DDL.data("kendoDropDownList").dataSource.read();

This partially works, it executes the server side read event, but it does not execute the JS function which should dynamically get the parameters for the server side read event. The function assigned in .Data [see below] (GetAllDescriptorsData) only executes once - when the page loads, it does not re-execute when . call read() [see above]. 

My question is, How can I force a read and get new parameters?

 @(Html.Kendo().DropDownList()
                        .Name(YearDescriptorID)
                          .DataSource(source =>
                          {
                              source.Read(read =>
                              {
                                  var IsSpouse = Model.IsSpouse ? "1" : "0";
                                  read.Action("GetAllDescriptors", "Income").Data("GetAllDescriptorsData("+ Model.PersonalKey + "," + IsSpouse + ")");
                              
                              })
                               .ServerFiltering(true);
                          })
                        .AutoBind(false)
                        .DataTextField("DisplayText")
                        .DataValueField("IncomeKey")
                        .Events(e =>
                        {
                            e.Change("onChangeYearDescriptor");
                            e.DataBound("onDataboundYearDescriptor");
                        })
                )

Adam King
Top achievements
Rank 1
 answered on 25 Apr 2017
12 answers
2.0K+ views

Assuming I have the following HTML element
<div id="grid" />
the following script works:

$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 }
]
});

I would like the following to work instead (and it doesn't):

$("#grid").kendoGrid({
columns: [
{ field: 0 },
{ field: 1 }
],
dataSource: [
[ "Jane Doe", 30 ],
[ "John Doe", 33 ]
]
});

I can make it work using a workaround like the sample below, but this is an ugly workaround - any chance this could be placed into the framework?
The reason is that JSON that contains array or arrays cost much less to transfer then a JSON with array of objects with named fields

function convertArrayToObjects(arrayOfArrays) {
            if (!Array.isArray(arrayOfArrays))
                return arrayOfArrays;
 
            var arrayOfObjects = [];
            arrayOfArrays.forEach(function (arr) {
                if (!Array.isArray(arr))
                    arrayOfObjects.push(arr);
                else { // need to convert array to object
                    var obj = {};
                    var hasOwnProp = Object.prototype.hasOwnProperty;
                    for (var k in arr) {
                        if (+k === (k & 0x7fffffff) && hasOwnProp.call(arr, k)) {
                            obj['_'+k] = arr[k];
                        }
                    }
 
                    arrayOfObjects.push(obj);
                }
            });
 
            return arrayOfObjects;
        }
$("#grid").kendoGrid({
                columns: [
                  { field: "_0" },
                  { field: "_1" }
                ],
                dataSource: convertArrayToObjects([
                  ["Jane Doe", 30],
                  ["John Doe", 33]
                ])
            });
Boyan Dimitrov
Telerik team
 answered on 25 Apr 2017
1 answer
274 views

Is it possibile to add a context menu to cell.

The idea is add a right click on cell, header, footer to format it.

Any other options/idea is appreciated

Stefan
Telerik team
 answered on 25 Apr 2017
12 answers
2.7K+ views
In a grid I have a custom command which must call a controller method in Asp.Net Mvc and pass to it the same DataSourceRequest that originated the currently shown grid rows. How can I achieve it?
In alternative, I can also pass the dataSource.view to it, but in this case I don't know of which type I should declare the parameter in the controller method...

What I need in the end in the controller method is an IEnumerable<T> containing all the currently visible rows, possibly respecting the ordering shown but  regardless of grouping.

Thanks for any suggestion,
Stefano
Alex Hajigeorgieva
Telerik team
 answered on 25 Apr 2017
1 answer
2.1K+ views

I am using a KendoUI grid to display data on screen. Each row has a set of buttons that trigger various actions. One button triggers a modal popup asking the user to select a child item (generated via an ajax call) of the row before continuing on with the action. The first time the button is triggered, the select is correctly filled, however, on subsequent calls the select box is left blank as if the element doesn't exist. Any idea what I am doing wrong here:

 

 

    $(document).ready(function () {
      $('#formGrid').delegate('.exportButton', 'click', function () {
         var button = $(this);
         var formId = button.attr("data-form-id");
         var formImplementationId = button.attr("data-form-implementation-id");
         var formVersion = Number(button.attr("data-form-version"));

         $.ajax({
           url: AppSettings["BaseUrl"] + "/xxxx/GetVersions?formId=" + formId + "&formImplementationId=" + formImplementationId,
           dataType: 'json',
           success: function (data) {
             $.each(data, function (index) {
               var item = data[index];
               $("#exportVersion").append("<option value=\"" + item.Version + "\">Version: " + item.Version + " (" + item.EffectiveDate + ")</option>")
             });
           }
         });

         var kendoWindow = $("<div />").kendoWindow({
           title: "Export Form",
           resizable: false,
           modal: true
         });

         kendoWindow.data("kendoWindow")
           .content($("#select-export-version").html())
           .center().open();

         kendoWindow
           .find(".export-confirm")
           .click(function () {
             if ($(this).hasClass("export-confirm-yes")) {
               window.location = AppSettings["BaseUrl"] + "/xxxx/ExportForm?formId=" + formId + "&formImplementationId=" + formImplementationId + "&formVersion=" + $('#exportVersion').val()
             }

             kendoWindow.data("kendoWindow").close();
           })
           .end()
         });
      });

      $('#formGrid').kendoGrid({
        dataSource: {
          transport: {
            read: {
              url: '@Url.EncodedAction("GetForms", "xxxx")',
              dataType: "json",
              contentType: "application/json"
            }
          },
          schema: {
            model: {
              fields: {
                FormName: { type: "string" },
                ContractName: { type: "string" },
                EffectiveDate: { type: "date" },
                UserName: { type: "string" },
                IsDraft: { type: "string" },
                FormId: { type: "string" },
                FormImplementationId: { type: "string" },
                FormVersion: { type: "number" }
              }
            }
          },
          pageSize: 15,
          sort: [{ field: "FormName", dir: "asc" }]
        },
        sortable: true,
        pageable: true,
        columns: [
          {field: "FormName", title: "Form"},
          {field: "Version", title: "Version", width: 100},
          {field: "ContractName", title: "Contract", width: 150},
          {field: "EffectiveDate", title: "Last Modified", format: "{0:MM/dd/yyyy}"},
          {title: "User", field: "UserName"},
          {field: "Status", title: "Status", width: 120},
          {
            template: function (dataItem) {
              buttons = '<div class="buttonDiv">';
              buttons += '<button class="exportButton" title="Export Form" data-form-id="' + dataItem.FormId + '" data-form-implementation-id="' + dataItem.FormImplementationId + '" data-form-version="' + dataItem.Version + '"><span class="glyphicon glyphicon-open"></span></button>'
              buttons += '</div>';

              return buttons;
            },
          }
        ]
      });
    });

    <script id="select-export-version" type="text/x-kendo-template">
      <div id="export-file-modal" class="maintenance-modal">
        <p>
          <label for="exportVersion">Select the version of the form to export:</label><br />
          <select id="exportVersion"></select>
        </p>
        <div id="export-buttons" class="text-center same-width">
          <button class="export-confirm export-confirm-yes k-button k-default">Export</button>
          <button class="export-confirm export-confirm-no k-button k-primary">Cancel</button>
        </div>
      </div>
    </script>

Boyan Dimitrov
Telerik team
 answered on 25 Apr 2017
2 answers
358 views

In a non-MVVM enviroment, I can define the child entities of my hierarchical datasource by setting the schema:

var datasource = new kendo.data.HierarchicalDataSource({  
    data: [ /*... */ ],  
    schema: { 
        model: {
            children: "Assets"
        }
    }
});

 

In a viewModel I am defining the same datasource like this:

function buildDataSource(data) {
     _.map(data.assets, function(item) {
        item.type = "folder";
   });
   var tree = unflatten(data.assets);
   return tree;
}
 
function loadTreeView(dataSource) {
    documentsModel.set("treeviewSource", kendo.observableHierarchy(dataSource));
    kendo.bind($("#Treeview"), documentsModel);
}
 
$.ajax({
     dataType: "json",
     url: "scripts/assets.json"
})
.then(buildDataSource)
.then(loadTreeView);

 

What is happening here, that I am loading a flat array of json objects from a file (later api endpoint) and unflatten this list, so it is in a hierachical format. The method to unflatten this array is naming the children "Assets". Running this, the treeview fails to display. If I change the unflatten method to name those children "items", the treebiew works.

You can reproduce this in this Dojo: http://dojo.telerik.com/UTOBe/3

Change items, to anything else and it stops working. How can I configure the kendo.observableHierarchy, so it uses any other property then "items" to determine if an object has children using a viewModel?

Marco
Top achievements
Rank 1
 answered on 25 Apr 2017
2 answers
132 views

Destroying and recreating a Toolbar in the same DOM element causes problem with Splitbutton expansion via keyboard.  To reproduce:

1.  Create a toolbar with a splitbutton.  Using the keyboard, tab to the splitbutton and use alt-down to expand it.  Works great.

2.  Destroy the toolbar with .destroy(), and empty the containing DOM element.

3.  Create a toolbar with a splitbutton in the same (now empty) DOM.

4.  Tab to the splitbutton and press alt-down.  The splitbutton expands and immediately closes.

Demonstrated here:  http://dojo.telerik.com/@richm/odATu

Any advice is greatly appreciated!
Rich
Top achievements
Rank 1
 answered on 24 Apr 2017
3 answers
164 views

I need to put a Registered Sign SuperScript in Combo. I managed to put a Registered Sign, but not in a superscript. It worked in the template, but when the user selects it, the html tags are displayed to the user as text in the input element.

The following link contains things that I tried:

http://dojo.telerik.com/eWAWO/2

 

Joana
Telerik team
 answered on 24 Apr 2017
4 answers
193 views
I am using a kendo grid and one of the columns uses a MultiSelectFor. I am also using a Sortable with the multiselect so users can change the ordering of the multiselect values but when I click out of the multiselect and it goes to write back to the grid it doesn't write back in the selected order but only the order in which I selected the values. I attached some images to show what I mean. 
Alex
Top achievements
Rank 1
 answered on 24 Apr 2017
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
Drag and Drop
Application
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
DropDownTree
ListBox
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
Styling
ColorPicker
Pager
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
Licensing
PivotGridV2
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
LLM Kit
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?