Telerik Forums
UI for ASP.NET MVC Forum
1 answer
270 views

Hi,

I need some help with the aggregate feature please. The sum aggregates are not displayed at the footer of the grid. The correct data is received however.

I Have an MVC backend and use the DatasourceRequest object, but because of the fact I am using angular, I cannot work with the MVC wrappers. Therefore I use the following JS for the grid options:

$scope.gridOptions = {
                // 1. DATASOURCE
                "dataSource": {
                    "type": 'aspnetmvc-ajax',
                    "transport": {
                        "read": { "url": myReadUrl() },
                        "update": { "url": myUpdateUrl() },
                        "create": { "url": myCreateUrl() },
                    },
                    "serverPaging": true,
                    "pageSize": 20,
                    "serverSorting": true,
                    "serverFiltering": true,
                    "sort": { "field": "Datum", "dir": "desc" },
                    "schema": {
                        model: {
                            "id": "Id",
                            "fields": {
                                "Id": { "type": "number" },
                                "Datum": { "type": "date", validation: { required: true } },
                                "​CountOk": { "type": "number", "validation": { required: true, min: 0 } },
                            },
                        },
                        "data": "Data",
                        "total": "Total",
                        "errors": "Errors",
                        "aggregates": "AggregateResults"
                    },
                    "serverAggregates": true,
                    "aggregate": [field: "​CountOk", aggregate: "sum" },  ]
 
                },
                // 2. COLUMNS
                "columns": [
                    {
                        "title": "Date",
                        "field": "Datum",
                        "format": "{0:d}",
                    }, {
                                "title": "OK",
                                "field": "CountOk",
                                "width": 100,
                                "format": "{0:0}",
                                "aggregates": ["sum"],
                     }, {
                        "command": [
                            { "name": "edit", "buttonType": "ImageAndText" },
                        ],
                    }
                ],
 
                // 3. GRID FEATURES
                "editable": {
                    "mode": "inline",
                    "create": true,
                    "update": true,
                    "destroy": false
                },
                "toolbar": [
                    { "name": 'create', "buttonType": "ImageAndText", "text": "​New" },
                ],
                "pageable": true,
                "sortable": true,
                "scrollable": true,
                 },
            }; 

 

 The received data contains the values, but it seems MVC datasource added some things here:

{"Data":[{"Id":5,"ItemId":4,"Datum":"\/Date(1447023600000)\/","CountOk":3}],"Total":1,
"AggregateResults":[{"Value":3,"Member":"CountOk","FormattedValue":3,"ItemCount":0,"Caption":null,"FunctionName":"Sum_CountOk_21409671","AggregateMethodName":"Sum"}],"Errors":null}

 

Thank you so much for helping me out here!

 

Daniel
Telerik team
 answered on 12 Nov 2015
1 answer
141 views

My upload control works fine for the first file but not the second.  The "Select" box still allows me to pick a second file, but no events fire.  The files I'm using are very small (a few K) so the first upload is almost instant.

 Here is my control:

 

@(Html.Kendo().Upload()
       .Name("invoiceUpload")
       .Multiple(true)
       .ShowFileList(true)       
       .HtmlAttributes(new { style = "margin-bottom: 10px;" })
       .Async(a => a
           .Save("Invoice", "Upload", new { format = @Model.Format })
           .AutoUpload(true)
       )
       .Events(events => events
           .Success("onSuccess")
           .Select("onSelect")
           .Error("error_handler")
           .Upload("onUpload")
           )
       )

 

The JS events are just alerts to see if anything is happening, they all fire the first time but none for for subsequent file selects.

 I know I'm not giving a ton of info, hoping I'm just missing something obvious.  Please let me know if you need more info.  Thanks in advance to any responders.

 

 

Dimiter Madjarov
Telerik team
 answered on 12 Nov 2015
2 answers
1.3K+ views

I'm having a problem with my grid.  The paging is not working when the datasource options are used.

My code is as follows:

 

@(Html.Kendo().Grid(Model)
      .Name("Grid")
      .Columns(columns =>
        {
          columns.Bound(c => c.status).Title("Status")
        }
      )

            .Pageable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(30)
          .Filter(filters =>
              {
                  filters.Add(status => status.requirementstatus).Contains("2");
              }
          )
      )
)

 

If I remove dtaousrce completely all the results are returned and the grid pages perfectly.  What am I doing wrong?

Plamen
Telerik team
 answered on 12 Nov 2015
0 answers
129 views

Hello,

I need to incorporate KnockoutJS to the project I'm creating.

I added KnockoutJS to a TextBox and it works!

Here's the code

01.@{
02.    var xx = Html.Kendo().TextBox()
03.        .Name("name11");
04. 
05.    Dictionary<string, object> attrs = new Dictionary<string, object>();
06. 
07.    attrs.Add("data-bind", "textInput: name");
08. 
09.    xx.HtmlAttributes(attrs);
10.    xx.Render();
11.}

 

But when I try to add KnockoutJS to a ComboBox using the same technique it doesn't work. I've tried using Knockout-Kendo v0.9.5 but it doesn't work too :(

Here's my code:

01.@{
02.    var aa = Html.Kendo().ComboBox()
03.        .Name("comboBox_moneda")
04.        .DataValueField("ID")
05.        .DataTextField("Product")
06.        .BindTo(@Model.Products)
07.        .Filter(FilterType.StartsWith);
08. 
09.        var dic = new Dictionary<string, object>();
10. 
11.        dic.Add("data-binding", "kendoComboBox: { value: selectedChoice }");
12. 
13.        aa.HtmlAttributes(dic);
14. 
15.        aa.Render();
16.}

 

Here's my ViewModel for the two code snippets above

1.var viewModel = {
2.    name: ko.observable(),
3.    selectedChoice: ko.observable()
4.};
5. 
6.ko.applyBindings(viewModel);
 

How can I fix this?

Thank you,

Mike.

Mike
Top achievements
Rank 1
 asked on 11 Nov 2015
4 answers
135 views

Hello,

I’m trying to use a @helper inside a Telerik Window widget but it doesn’t work as expected. If I use the @helper then it shows the TextBox widget in the main page without opening/showing the Window widget but the labels are shown as expected however if I write the code in the @helper directly in the Window widget then it works as expected. Why this strange behavior?

Here's the code

 â€‹

01.@helper MakeTextBox1(string name, string description)
02.{
03.    <li>
04.        <label for="@name">@description</label>
05.        @{
06.            var x = Html.Kendo().TextBox()
07.                .Name(@name);
08. 
09.            x.Render();
10.        }
11.    </li>
12.}
13. 
14.@(Html.Kendo().Window()
15.    .Name("window_CreateProduct")
16.    .Title("Product")
17.    .Content(@<text>
18.        <div style="text-align: center;">
19.            <form id="form">
20.                <ul class="fieldlist">
21. 
22.                    // Doesn't work
23.                    @MakeTextBoxNumeric1("amount", "Amount")
24. 
25.                    // It works!
26.                    <li>
27.                        <label for="numeric_Price">Price: </label>
28.                        @(Html.Kendo().NumericTextBox()
29.                            .Name("numeric_Price")
30.                        )
31.                    </li>
32.                </ul>
33.            </form>
34. 
35.        </div>
36.    </text>)
37.    .Draggable()
38.    .Visible(false)
39.    .Modal(true)
40.    .Resizable(x => x.Enabled(false))
41.    .Events(x => x.Open("onOpen_window"))
42.)

 

Can anyone help me to solve this?

 Thank you.

Mike
Top achievements
Rank 1
 answered on 11 Nov 2015
2 answers
183 views

Hi, i'm using a kendo grid for server paging, sorting and filtering and now i would like to add grouping functionality:

I use "function mode" to read data, so dataSource is configured as:

let dataSource: any = {
                batch: true,
                serverPaging: true,
                serverSorting: true,
                serverFiltering: true,
                serverGrouping: true,
                page: 1,
                pageSize: 20,
                transport:
                {
                    read: function (options)
                    {

kendo.data.transports["aspnetmvc-ajax"].fn.options.options = { prefix: '' };
                        let request = kendo.data.transports["aspnetmvc-ajax"].fn.options.parameterMap(options.data, "read", false);

                        thisObject.httpService.GetNodes(request)
                        .then(function (args: IHttpServiceParameters)
                        {
                            options.success(args.data);
                        });
                   }
                },
                schema:
                {
                    data: function (data)
                    {
                        return data.Data;
                    },
                    total: function (data)
                    {
                        return data.Total;
                    },
                    groups: function (data)
                    {
                        return data.Data;
                    },
                    model: model
                }
     }

 

 

Claudio
Top achievements
Rank 2
Bronze
Bronze
Iron
 answered on 11 Nov 2015
1 answer
439 views

Hi Telerik,

 

I'm usingASP.NET MVC Grid and I want using Column Template in server side but it's not working with my code:

<div id="clientsDb">
    @(Html.Kendo().Grid<vw_Products>()
          .Name("grid")
          .Columns(columns =>
          {
              columns.Template(item => "<img class='product-photo' src='" + ImageModel.GetThumbnail(item.Images) + "' alt='" + item.Title + "' /></td>")
                  .Width(140).Title("Picture");
              columns.Bound(c => c.Title).Title("Product Name").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
              columns.Bound(c => c.Price).Title("Price").Width(300).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
          })
          .HtmlAttributes(new { style = "height: 700px;" })
          .Scrollable()
          .Groupable()
          .Sortable()
          .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
          .Pageable(pageable => pageable
              .Refresh(true)
              .PageSizes(pageSizes)
              .ButtonCount(5))
          .DataSource(dataSource => dataSource
              .Ajax()
              .PageSize(30)
              .Read(read => read.Action("Products_Read", "Home"))
          )
    )
</div>

I think my set up is ok but it's not working, the column Template is Empty plz help me. Thanks

columns.Template(item => "<img class='product-photo' src='" + ImageModel.GetThumbnail(item.Images) + "' alt='" + item.Title + "' /></td>")

 

Plamen
Telerik team
 answered on 11 Nov 2015
3 answers
224 views

Hi,

I'm trying to use the grid component in a huge legacy ASP.NET MVC 5 project. For some reason the ​Html.Kendo().Grid() helper does not serialize my grid's data if I am using it in this project, but it does serialize the data if I use it in a brandnew ASP.NET MVC project.

I used the same source code in the view for both projects:

 

@{
    var dummy = new List<DummyModel>
    {
        new DummyModel
        {
            Col1 = "Foo1",
            Col2 = "Bar1"
        },
        new DummyModel
        {
            Col1 = "Foo2",
            Col2 = "Bar2"
        }
    };
}
 
@(Html.Kendo().Grid(dummy).Name("MyGrid")
      .Columns(col =>
      {
          col.Bound(c => c.Col1);
          col.Bound(c => c.Col2);
      }))

 

In a brand new MVC5 project, this renders  the following html / js code blocks: 

 

 

<div class="k-widget k-grid" id="MyGrid">
 
    <table>
        <colgroup>
            <col/><col/>
        </colgroup><thead class="k-grid-header">
        <tr>
            <th class="k-header" data-field="Col1" data-index="0" data-title="Col1" scope="col">
                <span class="k-link">Col1</span></th><th class="k-header" data-field="Col2" data-index="1" data-title="Col2" scope="col">
                <span class="k-link">Col2</span></th>
        </tr>
        </thead><tbody>
        <tr>
            <td>Foo1</td><td>Bar1</td>
        </tr><tr class="k-alt">
            <td>Foo2</td><td>Bar2</td>
        </tr>
        </tbody>
    </table>
</div>
<script>
    jQuery(function() {
        jQuery("#MyGrid").kendoGrid({
            "columns": [{ "title": "Col1", "headerAttributes": { "data-field": "Col1", "data-title": "Col1" }, "field": "Col1", "encoded": true }, { "title": "Col2", "headerAttributes": { "data-field": "Col2", "data-title": "Col2" }, "field": "Col2", "encoded": true }], "scrollable": false, "messages": { "noRecords": "No records available." }, "autoBind": false,
            "dataSource": {
                "type": (function() {
                    if (kendo.data.transports['aspnetmvc-server']) {
                        return 'aspnetmvc-server';
                    } else {
                        throw new Error('The kendo.aspnetmvc.min.js script is not included.');
                    }
                })(),
                "transport": { "read": { "url": "" }, "prefix": "MyGrid-" },
                "serverPaging": true,
                "serverSorting": true,
                "serverFiltering": true,
                "serverGrouping": true,
                "serverAggregates": true,
                "filter": [],
                "schema": { "data": "Data", "total": "Total", "errors": "Errors", "model": { "fields": { "Col1": { "type": "string" }, "Col2": { "type": "string" } } } }
            }
        });
    });
</script>​

 

This works fine and the table is displayed correctly.

 

​However, in my legacy project this renders the following html / js code blocks: 

 

<div class="k-widget k-grid" id="MyGrid">
    <table>
        <colgroup></colgroup><thead class="k-grid-header"></thead><tbody>
        <tr></tr><tr class="k-alt"></tr>
        </tbody>
    </table>
</div>
<script>
    jQuery(function() {
        jQuery("#MyGrid").kendoGrid({
            "scrollable": false, "messages": { "noRecords": "Keine Aufzeichnungen zur Verfügung." }, "autoBind": false,
            "dataSource": {
                "type": (function() {
                    if (kendo.data.transports['aspnetmvc-server']) {
                        return 'aspnetmvc-server';
                    } else {
                        throw new Error('The kendo.aspnetmvc.min.js script is not included.');
                    }
                })(),
                "transport": { "read": { "url": "" }, "prefix": "MyGrid-" },
                "serverPaging": true,
                "serverSorting": true,
                "serverFiltering": true,
                "serverGrouping": true,
                "serverAggregates": true,
                "filter": [],
                "schema": { "data": "Data", "total": "Total", "errors": "Errors", "model": { "fields": { "Col1": { "type": "string" }, "Col2": { "type": "string" } } } }
            }
        });
    });
</script>

 

The js code is identical to the brand new MVC 5 project, but the html code is missing the serialized data, which results in the table not being displayed correctly. You can easily see this by the fact that the strings "foo" or "bar" are nowhere in the source code.

 

I have double-checked that both projects are using the same Kendo.Mvc.dll reference, so that can't be the problem. I've also read the manual twice on how to set up Kendo UI twice and that did not help, so now I am stuck.

 Thanks in advance for your help,

 Adrian

Georgi Krustev
Telerik team
 answered on 11 Nov 2015
1 answer
79 views

Hi,

We encountered "internet explorer has stopped working" issue when adding rows to grid. The IE version is 11.

Based on our investigation, the issue seems is due to we are calling the following javascript function after we adding new row to the grid. 

Could you provide some pinions on this issue or suggest how to investigate the Internet explorer stop working issue?

 â€‹

function Reset(id) {
 
 
    //reset inputs
    var inputs = $("#" + id + " input");
    for (var m = 0; m < inputs.length; m++) {
        if (inputs[m].id != "") {
            $("#" + inputs[m].id).val('');
        }
    }
 
    //reset kendoNumericTextBox
    var currency = $("#" + id + " [data-role=numerictextbox]");
    for (var m = 0; m < currency.length; m++) {
        if (currency[m].id != "") {
            $("#" + currency[m].id).data("kendoNumericTextBox").value('');
        }
    }
 
    //reset kendoDateTimePicker
    var picker = $("#" + id + " [data-role=datetimepicker]");
 
    for (var m = 0; m < picker.length; m++) {
        if (picker[m].id != "") {
            $("#" + picker[m].id).value('');
            $("#" + picker[m].id).blur();
        }
    }
 
    //reset kendoDropDownList
    var dropDown = $("#" + id + " [data-role=dropdownlist]");
    for (var m = 0; m < dropDown.length; m++) {
        if (dropDown[m].id != "") {
            $("#" + dropDown[m].id).data("kendoDropDownList").value('');
        }
    }
 
    //hidden error message
    var spans = $("#" + id + " [class='k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error']");
    if (spans.length > 0) {
        spans.addClass("hidden");
    }
 
}

 

 

Nikolay Rusev
Telerik team
 answered on 11 Nov 2015
3 answers
208 views

Controllercode:

01.namespace vEF_AspApplication.Controllers
02.{
03.    public class AddressesController : Controller
04.    {
05.        private MyDataModelContext db = new MyDataModelContext();
06. 
07.        // GET: Addresses
08.        public async Task<ActionResult> Index()
09.        {
10.            var addresses = db.Addresses.Include(a => a.FormOfAddress).Include(a => a.Title);
11.            return View(await addresses.ToListAsync());
12.        }
13.    }
14.}

Viewcode:

01.@(Html.Kendo().MobileView()
02.    .Title("EntityFramework DataAccess")
03.    .Name("Index")
04.    .Content(@<text>
05.        <div id="AddressList">
06.          @(Html.Kendo().Grid<vEF_Library.Address>()
07.          .Name("AddressGrid")
08.          .Columns(columns =>
09.              {
10.                  columns.Bound(c => c.LastName);
11.                  columns.Bound(c => c.FirstName);
12.                  columns.Bound(c => c.Phone);
13.              })
14.                .HtmlAttributes(new { style = "height: 100%;" })
15.                .HtmlAttributes(new { style = "width: 100%;" })
16.                .Scrollable()
17.                //.Groupable()
18.                .Sortable()
19.                .Pageable(pageable => pageable
20.                .Refresh(true)
21.                .PageSizes(true)
22.                .ButtonCount(10))
23.                .DataSource(dataSource => dataSource
24.                .Ajax()
25.                .Read(read => read.Action("Index", "Addresses"))
26.                )
27.            )
28.        </div>
29.    </text>)
30.)

What is wrong?

Alexander Popov
Telerik team
 answered on 11 Nov 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
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
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
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
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?