Hi,
If pass a invalid value to MultiSelect, it will break the UI with null pointer exception. Please see this example:
https://codesandbox.io/p/sandbox/zen-pasteur-fw7rrt?file=%2Fapp%2Fmain.jsx%3A13%2C20
This only happens if data is an array of objects, and textField property is used.
It is possible invalid values are passed to multiselect when it is a controlled component. I am hoping MultiSelect can handle data error mor gracefully.
Thanks,
Jie
Need an example of multi-select tree API data.
Found Similar for Dropdown - https://stackblitz.com/edit/react-gr9hn2?file=app%2Fmain.jsx
The multi-select is placed outside of the chart component. The change of multi-select chart data is refreshing which ideally shouldn't be.
BasicGroupChart.js
/*
Use this for simple charts with the following type:
- bar
- column
- area
- line
*/
import * as React from 'react';
import { Chart, ChartTitle, ChartSubtitle, ChartSeries, ChartSeriesItem, ChartCategoryAxis, ChartCategoryAxisItem, ChartLegend, ChartLegendTitle, ChartTooltip, ChartAxisDefaults } from '@progress/kendo-react-charts';
import { IntlProvider } from "@progress/kendo-react-intl";
import 'hammerjs';
import { groupBy } from "@progress/kendo-data-query";
import { dateFormat } from '@insight/toolkit-react';
export const BasicGroupedChart = (props) => {
//set variables from properties passed
const chartType = props.chartType; // area, line, bar, column, etc
const title = props.title; // chart title
const subTitle = props.subTitle; //chart subtitle
const data = props.data; //chart data
const groupedByField = props.groupedByField; //field used for legend keys
const valueField = props.valueField; // field for values (y axis)
const categoryField = props.categoryField; // field for categories (x axis)
const valueFormat = props.valueFormat; // format for values in y axis (ex. c0 for currency no decimals and p for percent)
const labelFormat = props.labelFormat; // format for labels (ex c2 for currency with decimals, n0 for number, no decimals)
const showLabels = props.showLabels; //shows or hides value labels
const categoryTitle =props.categoryTitle; // title for the Category axis
const legendPosition = props.legendPosition; //position of the legend, top, right, bottom, etc
const legendTitle = props.legendTitle; //title of the legend
const tooltipFormat = props.tooltipFormat; // format for tooltip (ex "My tooltip {0:c}")
const locale = props.locale; // culture local (ex. "en-GB")
const showCategoryLabels = props.showCategoryLabels; // show the category axis labels
const legendVisible = props.legendVisible ?? true;
const stacked = props.stacked ?? false;
//const colorField = props.colorField ?? ""
//alert("DATA = " + JSON.stringify(data));
const series = groupBy(data, [
{
field: groupedByField,
},
]);
const mapSeries = (item, idx) => (
<ChartSeriesItem
key={idx}
data={item.items}
name={item.value}
field={valueField}
categoryField={categoryField}
type={chartType}
labels={{visible:showLabels, format: labelFormat}}
stack={stacked}
//colorField={colorField}
/>
);
return(
<IntlProvider locale={locale}><Chart><ChartLegend visible={legendVisible} position={legendPosition}><ChartLegendTitle text={legendTitle}></ChartLegendTitle></ChartLegend><ChartTitle text={title} /><ChartSubtitle text={subTitle} /><ChartCategoryAxis><ChartCategoryAxisItem title={{text: categoryTitle}} labels={{visible: showCategoryLabels}} /></ChartCategoryAxis><ChartAxisDefaults
labels={{
format: valueFormat
}}
/><ChartTooltip format={tooltipFormat} /><ChartSeries>
{series.map(mapSeries)}
{/*props.series.map(s => <ChartSeriesItem name={s.name} data={s.data} key={s.name} type="area"/>)*/}
</ChartSeries></Chart></IntlProvider>
);
};
Component Used - <BasicGroupedChart
chartType="column"
title="Invoice Breakdown by Product Category"
subTitle=""
data={spendPeriod?.spend ? spendPeriod?.spend : ""}
categoryField="group"
valueField="value"
groupedByField="label"
categoryTitle=""
legendPosition="bottom"
legendTitle=""
legendVisible={false}
tooltipFormat="{0:c}"
showLabels={true}
valueFormat="c2"
labelFormat="c2"
locale={accountInfo?.locale}
></BasicGroupedChart>Multi Select -
import { DropDownList, MultiSelect } from "@progress/kendo-react-dropdowns";
<MultiSelect
data={productNameData}
textField="label"
dataItemKey="value"
value={productName}
name="msCategory"
placeholder="All"
onChange={handleProductNameChange}
/>
const handleProductNameChange = (event) => {
setProductName(event.value);
setProductNameObject([...event.value]);
setProductNameLength(event.value.length)
};
Created one dummy Project -
https://stackblitz.com/edit/react-ab4fou-czgxv7?file=index.js
Multi select change, delete should not impact the chart.
I'm looking at the examples of virtualization found on https://www.telerik.com/kendo-react-ui/components/dropdowns/multiselect/virtualization/
There is a problem at the main.jsx file, when you look at the full source you can see that the project was set up using outdated approach that defaults back to React 17 :https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
Line that is outdated:
using the new Client Render API you will see that the scroll is glitching:
https://codesandbox.io/s/kendo-virtualization-problem-d4375s?file=/src/index.js
Hope someone has a simple solution?
I have a simple react view with a form that has two Kendo MultiSelect dropdowns ^v5.9.0. One with category and the othe subcategory.
CategoryDS: [{categoryId: 1, name: "Category-A"}, {categoryId: 2, name: "Category-B"}, {categoryId: 3, name: "Category-C"}], SubCategoryDS: [{SubCatId: 101, name: "CatA-SubCat1"}, {SubCatId: 102, name: "CatA-SubCat2"}, {SubCatId: 103, name: "CatB-SubCat1"}, {SubCatId: 104, name: "CatB-SubCat2"}, {SubCatId: 105, name: "CatC-SubCat1"}]
<MultiSelect
data={subCategoryDS}
value={subCategories}
onChange={handleChange}
style={{
width: "300px",
}}
placeholder="Please select ..."
/>
In a scenario when selected category: Category-A, Category-B and in sub category MultiSelect: CatA-SubCat1, CatB-SubCat1, CatB-SubCat2. When we decide to remove Category-A from category MultiSelect we would like subcategory MultiSelect selection to also remove CatA-SubCat1 from selection to relect our action. How do we handle this to show our intention? For context sake we have onchange method of category MultiSelect to handle the assigning of our subcategory multiselct data like so:
let subcategoryDropdownList = document.getElementById(`subcategory-multi-dropdown`).parentElement.parentElement as unknown as MultiSelect;
subcategoryDropdownList.data = subCategories; //trying this according to docs
subcategoryDropdownList.value = subCategories; //trying this hailmary and pray
However we're getting the object alright but assigning anything to it like so doesn't work. Neither does letting React work with data and state to follow convention like :
const [subCategories, setSubCategories] = React.useState([]);
setSubCategories((pv) => ({
...pv,
{ options }
}));
It would seems as if once the MultiSelect is touched and selection set it wouldn't respond to changes and it doesn't have MultiSelect.Refresh() void method like its jQuery equivalent. if anyone could please help would make my day as I'm loosing hair and going grey trying to solve this tough one. Many Thanks in advance
Hi,
We have an editable grid with multiple different editable field types outside of the basic TextInput including date fields, Combobox and multiselect. One requirement is to have the Enter key add a new row to the grid from the field in the last column - no mouse involvement, only keyboard navigation. With a field type of Text Input we can successfully implement with the onKeypress event. How can this event be implemented on the other field types that may be present as the editable field in the last column?
Example stackblitz here: https://stackblitz.com/edit/react-cw51ay-yswpbg?file=app%2Fmain.jsx