Telerik Forums
Kendo UI for jQuery Forum
12 answers
2.5K+ 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
1.9K+ 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
325 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
100 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
105 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
148 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
3 answers
1.4K+ views
I can't get the Kendo upload control to work for files larger than 40 meg.  I first noticed it on my application, it will upload about 40% of a 40 meg file then the percent would start over to 0 again and continue to about 40% and do the same thing over and over again.  I thought maybe it was on my end until I went to the demo page at http://demos.kendoui.com/web/upload/async.html and noticed that it does exactly the same thing.  I tried it in both Chrome and Firefox with the same result.  Can someone help me with this?  I really need this to work.
Tsvetina
Telerik team
 answered on 24 Apr 2017
1 answer
471 views

Hi,

I'm using the Kendo UI Menu for Angular 1 to list projects users can access in a solution. Is it possible to use JSON objects received from a WebAPI directly as menuItems or will I have to remap these into simpler objects? In this demo you are using custom attributes, will I be able to access these in the select event (how?)?

Further more, is it possible to access the datasource from another function in my Angular controller? I am currently storing the project ID in localstorage and if I'm able to use JSON objects or custom attributes in MenuItems I'd like to access the datasource so I can retrieve properties/attributes from the MenuItems.

BR,

Henrik

Dimitar
Telerik team
 answered on 24 Apr 2017
3 answers
375 views

I have a number of regular MVC grids that make their requests to controllers with additional data, and they make use of the Data attribute to call a function which returns an object. For example:

@(Html.Kendo().Grid<Model>()
                .Name("Grid")
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .ServerOperation(true)
                    .Read(read => read
                        .Action("ActionName", "ControllerName")
                        .Data("FunctionName")
                    )
                )

...and this works fine, but for the PivotGrid I can't seem to find a matching equivalent. The configuration seems to be quite different in fact:

@(Html.Kendo().PivotGrid<Model>()
                .Name("pivotGrid")
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Transport(transport => transport
                        .Read("Action", "Controller")
                    )
                    .Events(ev => ev.RequestEnd("onRequestEnd").RequestStart("onRequestStart"))

I cannot seem to use the same configuration (Transport instead of Read), and I cannot find anywhere the "Data" action can be assigned. I can set this attribute to the relevant javascript function after page load using:

$("#pivotGrid").data('kendoPivotGrid').dataSource.transport.options.read.data = pivotSync;

...but I would like to be able to set this during the initial configuration of the pivot grid. Is this possible?

Tom
Top achievements
Rank 1
Iron
 answered on 24 Apr 2017
1 answer
188 views

I have successfully set up several KendoUI Grids, but I cannot get one using server-side paging to work. I modified my rest service so I will return a total value (hard coded right now).

Below please find the JSON that is put out and the javascript. Any help would be greatly appreciated.

$(document).ready(function(){
 
        // Setup Rest Service
        var loc = ( location.href );
        var url = loc.substring( 0, loc.lastIndexOf( "/" ) ) + "/xpRest.xsp/test/";
 
 
        dataSource = new kendo.data.DataSource({
            pageSize: 20,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true,            transport : {
                read : {
                    url : url + "READ",
                    dataType : "json"
                },
                type : "READ"
            },
            schema : {
                    total: "total",
                    model : {
                    id : "unid",
                    fields   : {
                        unid : {
                            type : "string",   
                            nullable : false
                        }, 
                            tckNbr : {
                            type : "string",
                            editable : false
                        },
                            tckSts : {
                            type : "string",
                            editable : false
                        }
                }
            }
        }
        });
 
            grid = $("#grid-databound-dataItem").kendoGrid({   
            dataSource : dataSource,
            height: 550,
            filterable: true,
            sortable: true,
            pageable: true,        
            columns : [        
                       {field : "tckNbr", title : "Number", type: "string"},
                       {field : "tckSts", title : "Status", type: "string"}
                       ]
            }).data("kendoGrid");
        });

 

  {
      "total":100,
        "data":
        [        
          {
              "tckNbr":"3031",
              "tckSts":"1 Not Assigned",
              "unid":"0014DA9095BF6D638625810700597A36",
              "tckReqs":"Bryan S Schmiedeler",
              "tckNts":
              [
                "Bryan DeBaun"
              ],
              "tckBUs":
              [
                "NAP\/IFI"
              ],
              "tckApps":"GTM",
              "tckType":"Issue",
              "tckPriority":"Medium"
          },         
          {
              "tckNbr":"3031",
              "tckSts":"1 Not Assigned",
              "unid":"00598976D88226D2862581070059AD25",
              "tckReqs":"Bryan S Schmiedeler",
              "tckNts":
              [
                "Bryan DeBaun"
              ],
              "tckBUs":
              [
                "NAP\/IFI"
              ],
              "tckApps":"GTM",
              "tckType":"Issue",
              "tckPriority":"Medium"
          }       
        ]
    }
]
Dimiter Topalov
Telerik team
 answered on 21 Apr 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?