This is a migrated thread and some comments may be shown as answers.

Need to have onClick Event on PanelBarItem of the <PanelBar> component

1 Answer 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vinod
Top achievements
Rank 1
Vinod asked on 18 Jul 2019, 01:52 PM

Hi, 

I am trying to use PanelBar within a drawer component. I want to be able to navigate on the click of PanelBarItem item. From what I gather from your website (https://www.telerik.com/kendo-react-ui/components/layout/api/PanelBarProps/) is that the onSelect() event is available on the PanelBar and not on PanelBarItem.

 

Could you please provide an example where in I could use the click of PanelBarItem for navigation purpose. 

I tried below code, but instead of <List> and <ListItem> I want to use PanelBar and PanelBarItem. Code below for your reference. Thank you. 

 

<Drawer
        variant="permanent"
        className={classNames(classes.drawer, {
          [classes.drawerOpen]: props.drawerOpen,
          [classes.drawerClose]: !props.drawerOpen
        })}
        classes={{
          paper: classNames({
            [classes.drawerOpen]: props.drawerOpen,
            [classes.drawerClose]: !props.drawerOpen
          })
        }}
        open={props.drawerOpen}
      >
        <List>
          {/* todo: offset for appbar */}
          <div className={classes.toolbar} />
          {props.data.map((item, index) => (
            <ListItem
              button
              key={index}
              component={Link}
              to={item.name}
              onClick={() => handleMenuItemClick(item)}
            >
              <img
                alt={item.title}
                src={`Images/Icons/24x24/${item.iconUrl}`}
              />
              <ListItemText
                className={classes.menuItemText}
                primary={item.displayName}
              />
            </ListItem>
          ))}
        </List>
      </Drawer>

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 Jul 2019, 07:20 AM
Hello, Vinod,

The individual items do not have a click event as the onSelect event contains the information which item has been clicked:

https://stackblitz.com/edit/react-6m6e7c?file=app/main.jsx

Is it possible, to share a use case where the onSelect event does not provide the needed information to execute the business logic.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Vinod
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or