在嵌入式ibm cognos仪表板中,“添加源代码”功能接受模块对象,该对象具有您要用作数据源的csv文件的定义或架构,在我的用例中,用户将上传自己的csv文件,如何我会自动生成其架构,并将其传递给addSource函数?
import React, { useRef } from "react";
import styled from "styled-components";
const TextAreaInput = styled.textarea`
height: ${props => props.idealHeight || "152px"};
min-height: 32px;
max-height: 320px;
line-height: 21px;
width: 100%;
resize: vertical;
box-sizing: border-box;
border: 1px solid rgb(217, 217, 217);
padding: 4px 11px;
text-size-adjust: 100%;
`;
function TextArea(props) {
const idealHeight = useRef(32);
const lastScrollHeight = useRef(30);
const textAreaRef = useRef(null);
console.log("ANOTHER RENDER...");
if (textAreaRef.current !== null && textAreaRef.current !== undefined) {
const scrollHeight = textAreaRef.current.scrollHeight;
// THIS NEXT LINE MAKES THE DELTA CALCULATION CORRECT ON 'SHRINKING'
// BUT STOPS THE RESIZING
// textAreaRef.current.style.height = "2px";
const delta = scrollHeight - lastScrollHeight.current;
console.log("Delta is: " + delta);
console.log("Last ScrollHeight: " + lastScrollHeight.current);
lastScrollHeight.current = scrollHeight;
console.log("Current ScrollHeight: " + lastScrollHeight.current);
idealHeight.current = idealHeight.current + delta;
console.log("IdealHeight :" + idealHeight.current);
}
return (
<TextAreaInput
placeholder={props.placeholder}
value={props.value}
onChange={e => props.setValue(e.target.value)}
ref={textAreaRef}
idealHeight={idealHeight.current + "px"}
/>
);
}
export default TextArea;
dashboardAPI.addSources([{
module: sampleModule,
name: 'Survey sample',
id: 'myUniqueId789'
}])