Telerik Forums
KendoReact Forum
1 answer
658 views
Hello Everyone!

I use Kendo react data grid. I have the filterable setting enabled. I have the state of the filter stored in the react state. When [onDataStateChange] fires, I save the new state - as in the demo. My problem is that the [onDataStateChange] event is fired whenever the text in the filter changes, which causes performance issues, especially if I use server side pagiing. Is it possible to define deboucing, or some other kind of search delay? I know I can delay the api call to the server side. But filtering over current data is in progress, which is an unwanted effect. In Jquery grid, the filter is fired after typing the Enter key, this is also sufficient. But I can't implement it for react grid.

Thank you very much.
Vlado

Stefan
Telerik team
 answered on 04 May 2021
1 answer
1.0K+ views

Hi All

I am using the below functional component.

It triggers the function setGridState1 when any sort, filter, etc changes are made but the rows do no actually change in the grid.

Is there something simple that I could be missing here


const ReferralListSeg: React.FC<ReferralListSecProps> = (props: ReferralListSecProps) => {
    const [referrals, setReferrals] = React.useState<Referral[]>([]);
    const [gridState, setGridState] = React.useState({ filter: null, group: null, skip: 0, sort: null, take: 100, editField: undefined });

    const setGridState1 = (e) => {
        const { filter, group, skip, sort, take } = e.dataState;
        const newState = { filter, group, skip, sort, take, editField: undefined };
        setGridState(newState);
    }

    const totalRecords = (): number => {
        return referrals.length;
    }

    React.useEffect(() => {
        axios.get(apiAppendCode(apiURL('/ClientReferralsOpen/' + props.clientid)))
            .then((response) => {
                setReferrals(response.data);
            }, (error) => {
                debugger;
            });
    }, []);

    React.useEffect(() => {
    }, [gridState, setGridState]);

    return (
        <div className="container-fluid">
            {referrals &&
                <Grid
                    filterable={true}
                    sortable={true}
                    resizable={true}
                    pageable={true}
                    data={referrals}
                    total={totalRecords()}
                    {...gridState}
                    onDataStateChange={setGridState1}
                >
                    <Column sortable={true} field="createdon" title="Created" width="150px" cell={KendoGridDateCell} />
                    <Column field="name" title="Name" width="250px" />
                    <Column field="status" title="Status" cell={KendoGridRefStatusCell} />
                    <Column filterable={false} cell={KendoGridNavRefCell} width="180px" />
                </Grid>
            }
        </div>
    );
}

Stefan
Telerik team
 answered on 03 May 2021
2 answers
489 views

Hi,

I have a requirement to implement an editable master-detailgrid. 

After updating a child-record, the master needs to be updated. The update is triggered by tabbing out of the current cell. Then the sum is calculated and updated in the master-grid. 

My problem is, that after updating the master-grid , the child looses its focus.

Here is a simplyfied version of my project:

https://stackblitz.com/edit/react-ctg3nj

Any help would be appreciated.

Regards

Waldemar
Top achievements
Rank 1
Iron
 updated answer on 30 Apr 2021
1 answer
360 views

This is a very straightforward question, and I'm sure the answer is as well, but I can't seem to figure it out. I want to be able to draw a simple shape, in this case, a circle. Here is what I did:

RenderSurface.jsx

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Surface } from '@progress/kendo-drawing';

import drawCircle from './DrawCircle';

class RenderSurface extends React.Component {
  surface;
  componentDidMount() {
    drawCircle(this.createSurface());
  }
  createSurface = () => {
    const element = ReactDOM.findDOMNode(this);

    this.surface = Surface.create(element);

    return this.surface;
  }
  render() {
    return (<div id="surface" />);
  }
}

export default RenderSurface;

 

DrawCircle.jsx

import { geometry } from '@progress/kendo-drawing';
const { Circle } = geometry;


export default function drawCircle(surface) {
  const circle = new Circle([100, 100], 80, {
    stroke: { color: "red", width: 1 },
    color: "rgb(255, 0, 0)",
  });

  surface.draw(circle);
}

 

App.js

import '@progress/kendo-theme-default/dist/all.css';
import './App.scss';
import React from 'react';
import RenderSurface from './components/RenderSurface';

function App() {
  return (
    <div className="App">
      <RenderSurface/>
    </div>
  );
}

export default App;

When I run this, I get the following error:

TypeError: _node_map__WEBPACK_IMPORTED_MODULE_4__.default[srcElement.nodeType] is not a constructor

I though it might have to do with bad import, but whatever I tried, it's always this error. What am I doing wrong?
Stefan
Telerik team
 answered on 30 Apr 2021
1 answer
260 views

Hi,

i'm using the popup component in Kendoreact and i tried to change the anmiation enter and exit direction from down and up to right and left with no luck any idea?

 

Thank You

Monther

Stefan
Telerik team
 answered on 30 Apr 2021
8 answers
1.5K+ views

How can i set the default rendered font in the KendoReact Editor? When the Editor renders, the content is set to the browser default font (times new roman for me). I don't want to enable users to CHANGE the font, I just want to set what the text looks like in the browser to fit the theme of the rest of my form. To further clarify, I don't want to have the editor serialize the font setting when submitting the form, and I don't want to add the font selector in the toolbar.  I just want the appearance of a different font in the editable area than browser default.

I see 2 examples in the Editor documentation.  The overview example appears to use browser default, and the Custom Rendering Example has the font set to a different font, but it is unclear how that is happening.

Overview Example:

https://www.telerik.com/kendo-react-ui/components/editor/

Custom Rendering Example:

https://www.telerik.com/kendo-react-ui/components/editor/custom-rendering/

 

Stefan
Telerik team
 answered on 29 Apr 2021
1 answer
974 views

Hello all!

So I have created a DropDownButton with four options like this:

handleTitleMenuClick = (e: any): void => {
    switch (e.itemIndex) {
        case0:
            this.openPartTypeModal();
            break;
        case1:
            this.openPartNameModal();
            break;
        case2:
            this.openAddSubPartModal();
            break;
        case3:
            this.deletePart();
            break;
        default:
            return;
    }
}

render =  () => {
    const titleMenuItems = [
        {text: "Change part type"},
        {text: "Rename part"},
        {text: "Add subpart", disabled: this.state.subParts.length >= this.state.maxSubParts},
        {text: "Delete part", disabled: this.state.subParts.length > 0}
    ];

    return (
        <div className="part-container">
            <div className="part-title">
                <div className="part-title-text">...</div>
                <div className="part-title-menu">
                    <DropDownButton buttonClass="part-title-menu-button"
                                    popupSettings={{popupClass: 'common-step-title-menu-container'}}
                                    icon={'more-vertical'}
                                    items={titleMenuItems}
                                    onItemClick={this.handleTitleMenuClick}
                    />
                </div>
            </div>
            <div className="part-content">...</div>
        </div>
    );
}

This works exactly like I intend it; I have four options in my dropdown and when I click on an option it behaves a expected.

However, this solution feels very clunky and I have been looking for a neater solution. What I would have deemed most intuitive was to have a "onClick" for each item, something like this:

const titleMenuItems = [
    {text: "Change part type", onClick: this.openPartTypeModal()},
    {text: "Rename part", onClick: this.openPartNameModal()},
    {text: "Add subpart", disabled: this.state.subParts.length >= this.state.maxSubParts, onClick: this.openAddSubPartModal()},
    {text: "Delete part", disabled: this.state.subParts.length > 0, onClick: this.deletePart()}
];

I have tried adding the above but that resulted in some strange rendering error (Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.). I have looked through the documentation but I have not found anything that could help me.

The closest I found was an onClick in https://www.telerik.com/kendo-react-ui/components/buttons/api/ButtonItemProps/ but I don't understand if it's applicable here, and if so, how to implement it.

Maybe there is no alternative?

Krissy
Telerik team
 answered on 29 Apr 2021
3 answers
307 views

I have a "list of components", rendered by a map. I have created a StackBlitz here: https://stackblitz.com/edit/react-ts-vieabu?file=index.tsx. Each "box" has a title div and a content div. When clicking on the title, the content should expand or collapse.

As you can see in the title I have a span with an image, which when clicked should display a dropdown menu. This menu has a couple of constraints that needs to be fulfilled:

  • It should open/close on clicking the ellipsis.
  • It should NOT open/close on hovering the ellipsis.
  • It should always close when clicking outside the opened menu.

So it should behave more or less exactly like a regular <select> dropdown, but I also need to be able to have custom elements and styling for each option in the menu. I have tried two approaches:

  1. I tried using the Menu component and using "openOnClick". The problem here is that I don't seem to be able to prevent opening on hover after every odd (first, third, fifth etc.) click.
  2. I tried using the Popup component and having a <ul> as menu element, but here I cannot do it so it closes when clicking outside the menu. I tried adding a document.addEventListener('click', ...) to the BoxContainer component but that did not help or I did something wrong.

What would you say is the best approach here? Menu, Popup or something else?

Martin
Top achievements
Rank 1
Veteran
Iron
 answered on 27 Apr 2021
1 answer
167 views

Hello, is there support to display inline style in the Editor?

When pasting html data in ViewHtml (popup) tool that has inline styles in the tags it removes the styles and I get just the tags and content :) Is there a way to keep the styles and display them in the editor ?

Stefan
Telerik team
 answered on 27 Apr 2021
1 answer
550 views

Hello, is there support to display inline style in the Editor?

When pasting html data in ViewHtml (popup) tool that has inline styles in the tags it removes the styles and I get just the tags and content :) Is there a way to keep the styles and display them in the editor ?

Stefan
Telerik team
 answered on 27 Apr 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?