How to toggle office-ui-fabric detailslist row selection using the entire row as a toggle instead of just using the small tiny checkbox

爷,独闯天下 提交于 2020-05-16 02:33:48

问题


I'm using Office UI Fabric React components and i'm trying to improve change the default selection behavior for a DetailsList. By default, there is a difference between clicking a row and clicking the tiny checkbox on the right. I want the same effects of the checkbox click to apply to the row click.

When you click the checkbox it toggles the row and does not deselect other rows like when I use a row click. You can also use shift click and control click and all the other nice types of clicks as well here.

How can I make it so that clicking on a row has the same functionality as clicking on one of the checkboxes?


回答1:


Try using this custom onRenderRow function for the DetailsList:

onRenderRow = (props: IDetailsRowProps, defaultRender?: IRenderFunction<IDetailsRowProps>): JSX.Element => {
    return (
      <div data-selection-toggle="true">
        {defaultRender && defaultRender(props)}
      </div>
    );
  };

Works for both SelectionMode.multiple and SelectionMode.single: https://codepen.io/anon/pen/YoEzzE



来源:https://stackoverflow.com/questions/56692224/how-to-toggle-office-ui-fabric-detailslist-row-selection-using-the-entire-row-as

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!