Telerik Forums
Kendo UI Integration Forum
5 answers
391 views

Hello,

I'm attempting to use the React wrappers (or maybe the new React components) with an MVC backend. 

 

In the native jQuery implementation we can just set the Datasource's transport.read property to an API endpoint, load the kendo.aspnetmvc.js library, and get database level filtering of our requests from the filtering/sorting/paging interactions on the grid. Like this

public JsonResult Billbacks([DataSourceRequest]DataSourceRequest request)
{
    var data= _context.Mytable;
    var results = data.ToDataSourceResult(request);
    return Json(results, JsonRequestBehavior.AllowGet);
}
dataSource = new kendo.data.DataSource({
  transport: {
    read: {
      url: '/my/api/endpoint',
      dataType: 'json'
    }
  },
  serverSorting: true,
  serverGrouping: true,
  serverPaging: true,
  serverFiltering: true,
  pageSize: 2,
  schema: {
     model: {
      fields: {
        Id: { type: 'number' }
      }
    },
  }
});

 

But, when I try this in the kendo grid react wrapper it isn't playing nicely with the ASP.NET MVC Kendo DataSourceResponse.

By default it returns an object like this:

{
  "Data": [
    {
      "Id": 1,
      "Amount": -50
    },
    {
      "Id": 2,
      "Amount": -99
    }
  ],
  "Total": 10,
  "AggregateResults": null,
  "Errors": null
}

 

The kendo.aspnetmvc enhanced grids know how to deal with this, but the react wrapper kendo grid just calls that response the data for row 0. If I return `Json(result.Data)` then I get the resulting data back, but the total number of results doesn't return so the grid can't show it's page numbers properly.

How is serverside paging supposed to work with the kendo react wrapped grid? Is the MVC DataSourceRequest/DataSourceResult controller stucture appropriate to use with it? Hopefully there's a way to do this without rewriting all that functionality (although to use redux to handle the API calls it seems based on your examples that re-writing that funcionality is indeed the way to do it).

IT Dept
Top achievements
Rank 1
 answered on 02 Feb 2018
1 answer
172 views

I want to call the resize() method onto the chart so it automatically resized upon rendering, but it throws this error:

kendo.all.js:124 Uncaught TypeError: r[n].call is not a function

Same thing happens with DataBound event. Demo here:

http://dojo.telerik.com/oPAFO

Stefan
Telerik team
 answered on 19 Jan 2018
4 answers
240 views

How does one set the culture of the numerictextbox component (or global for the entire react app for instance)?

I tried this:

<NumericTextBox culture='nl-NL' decimals={2} format='c2' min={0} round={false} spinners={false}/>

But this still shows the dollar sign and uses '.' as the decimal seperator instead of ','.

No errors, but doesn't work.

 

Vitali
Top achievements
Rank 1
 answered on 15 Jan 2018
3 answers
992 views

I am trying to manually select/deselect React Grid rows (using checkbox) while calling a React/Redux action state handler so I have a dynamically updated state variable containing the selected rows ID's. Here's my code:

dataBound={function(e) {
    var grid = this
        $('tbody > tr > td > .k-checkbox').on('click',  
        function(event){
            var row  = $(this).closest('tr')
            if(row.hasClass("k-state-selected")==false){
                console.log("OFF > ON")
                grid.select(row)
                updateSelection('selection',grid.selectedKeyNames())
            }
            else{
                console.log("ON > OFF")
                row.removeClass("k-state-selected")
                event.stopPropagation()
                updateSelection('selection',grid.selectedKeyNames())
            }
        })
    }
}

While the select action successfully updates the UI and the state variable, the removeClass function doesn't seem to work and the row/checkbox remains selected (after a UI rerender). The state handler does fire although obviously changes nothing state wise because the row UI remains selected. I tried calling the removeClass right after the select function to see if it works or not, and it still does not do anything. Am I missing something? Also, while removing the "k-state-selected" should technically "deselect" the row, how do I "uncheck" the required row checkbox?

Help would be appreciated.

Akhmad Agosto
Top achievements
Rank 1
 answered on 04 Jan 2018
5 answers
1.0K+ views

I am trying to refresh the grid after a certain event by another component. In case of Jquery, one will do this as below.

$('#GridName').data('kendoGrid').dataSource.read();

$('#GridName').data('kendoGrid').refresh();

 

How do i achieve this in React component?

I have tried wrapping the grid in another component and i triggering state change, but in that case i get datasource.fetch is not a function.

 

Stefan
Telerik team
 answered on 03 Jan 2018
3 answers
400 views

I'm not sure if this is an oversight or intentional, but setting the React Wrapper DatePicker component's enable config as false does disable the text input but not the datepicker button itself.

Demo here.

Or maybe I'm missing something, and there's a separate config to disable the datepicker button? The jQuery version does disable both of them.

Preslav
Telerik team
 answered on 26 Dec 2017
6 answers
565 views

I am using React+Redux along with React wrappers for the Kendo UI Grid component. Here's a crop of my code:

import React, { Component } from 'react'
import { Grid } from '@progress/kendo-grid-react-wrapper';
 
class InputOrderComponent extends Component {
    
    static propTypes = {
        ...
        actionAdd: PropTypes.func,
        ...
    }
    render() {
        const { inputOrder, actionSelect, listBranch, actionChange, actionAdd, actionRetrieveBranch,  } = this.props;
         
        return (
           .....
           <Grid
                                    dataSource={new kendo.data.DataSource({
                                        transport: {
                                            read: function(e){
                                                actionRetrieveBranch()
                                                .then(res =>{                                              
                                                    e.success(res)
                                                })                                           
                                            }
                                        },
                                    })}
                                     
                                    filterable={true}
                                    sortable={true}
                                    groupable={false}
                                    pageable={true}
                                    columns={[
                                        {title:"No", filterable: false, template: '#='+ ++record  +'#', width:44},
                                        {field:"branchCode", title:"Part Number"},
                                        {field:"branchDescription", title:"Part Description"},
                                        {field: "phone1", title:"HET", width:100},
                                        {field: "branchCode", title:"Action", width:120, template:"<button onClick=\"actionAdd.bind(this,'branchCode')\" type='button' class='k-button k-button-icontext'><i class='fa fa-plus-circle' style='margin-right: 5px'></i> Pilih</button>"},
                                    ]}
                                    dataBinding={function() {
                                        //this.setState({
                                            //record : (this.dataSource.page() -1) * this.dataSource.pageSize()
                                        //})
                                        console.log(this.dataSource.data())                                
                                    }
                                    }
                                />
                 ....
         )
    }
}

I'm having diffucilties having my onClick action recognized. While the onClick event does trigger, the actionAddaction isn't. It throws a "Uncaught ReferenceError: actionAdd is not defined
    at HTMLButtonElement.onclick (inputOrder:1)" error.

Is this related to how the documentation mentions that react components are not supported in templates? I'm also having difficulties replicating this documentation on how to add Row Numbers. Records, in the template, throws an undefined error just like the above, unless I initialize the record variable outside the main component class.

Help would be appreciated.

Stefan
Telerik team
 answered on 06 Dec 2017
7 answers
99 views

Hi

As the title says , when can we expect to have the Scheduler available with Vue Library?

 

Eric

Pavlina
Telerik team
 answered on 01 Dec 2017
1 answer
74 views

From https://docs.telerik.com/kendo-ui-wrappers-react/components/grid it says refer to demo app. That link is either not viewable or broken. Is there somewhere else I can look?

Editing with Redux
 
For a runnable example on how to edit the Grid by using Redux, refer to this demo application.

Stefan
Telerik team
 answered on 24 Nov 2017
1 answer
85 views

https://docs.telerik.com/kendo-ui-wrappers-react/components/menu

 

SyntaxError: Inline Babel script: JSX value should be either an expression or a quoted JSX text (7:15) 5 | 6 | const element = ( > 7 |
| ^ 8 |
9 | Item 1 10 | Item 2 at line 8

Stefan
Telerik team
 answered on 21 Nov 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?