Closed Poojatilekar closed 3 years ago
Hi, just upgraded to v4.1.0, which (almost) supports what you need!
Please check out the latest examples (in section Use Custom Icons)
Basically now we can do something like
const FileIcon = ({ onClick: defaultOnClick, className, path, name }) => {
const handleClick = () => {
openFile(name);
// or use 'path', which is the path to the clicked node in the root state
};
return <YourIcon onClick={ handleClick } />;
};
So when user clicks on the icon we can open the file.
If you mean onClick()
on the node name itself, unfortunately we don't seem to support this, but I will probably try to add this functionality in later versions : )
yup, i also would like to have this feature, when user click on the filename , not only the icon, it should able to trigger a event
@sunjeen yup this would be a nice one! And indeed this is on the plan
@sunjeen yup this would be a nice one! And indeed this is on the plan
Look forward to it, currently I have one projects is utilizing file tree components, thanks for adding it!
@sunjeen Hi, just released a new version that supports custom onClick()
for node name!
this is the doc for how to do it, basically if we want to open a file, we can add filePath
to each node data, then do
const onNameClick = (defaultOnClick, nodeData) => {
const { filePath } = nodeData;
openFile(filePath);
};
alternatively, if we don't want to include extra data, we can choose to derive the filePath using the file name
const onNameClick = (defaultOnClick, nodeData) => {
const { name } = nodeData;
const filePath = getFilePath(name);
openFile(filePath);
};
Please check it out and let me know if there is anything breaking 😃
@sunjeen Hi, just released a new version that supports custom
onClick()
for node name!this is the doc for how to do it, basically if we want to open a file, we can add
filePath
to each node data, then doconst onNameClick = (defaultOnClick, nodeData) => { const { filePath } = nodeData; openFile(filePath); };
alternatively, if we don't want to include extra data, we can choose to derive the filePath using the file name
const onNameClick = (defaultOnClick, nodeData) => { const { name } = nodeData; const filePath = getFilePath(name); openFile(filePath); };
Please check it out and let me know if there is anything breaking 😃
Thanks! I will try now!
On selection of file name I need to open that respective file How I will Open this?? May I know How to bind Onclick function to PDF File Name . do Urgent .