我正在尝试使用数据网格中的嵌套值对数据进行排序,但在数据网格列的 sortComparator 上未定义
代码:列数据设置:
{
headerName: 'Title',
field: `${this.props.type}.title`,
width: 500,
type: "string",
renderCell: (valueReceived) => this.getImageorVideoLogo(valueReceived.row),
sortComparator: this.titleSorting
}
titleSorting = (a,b)=>{
console.log(a);
console.log(b);
}
Run Code Online (Sandbox Code Playgroud)
数据网格:
<DataGrid
rows={rowsDataGrid}
columns={columnsDataGrid}
components={{
Toolbar: this.getSearchTextField
}}
pageSize={5}
rowsPerPageOptions={[5]}
// checkboxSelection
// disableSelectionOnClick
autoHeight
/>
Run Code Online (Sandbox Code Playgroud)
问题两个控制台打印未定义理想情况下,它应该给出整行 a 和行 b 或至少行 a 列数据和行 b 列数据
I am trying to restrict my key input in the text field to numbers or backspace or space so I am checking before I set state and preventing default behavior of event in other cases but I am not able to locate event.which property of event or keyCode for that matter.
I tried event.persist() to see but still the same there is no property by the name of which in event.
There is a which in nativeEvent of event …
我正在尝试将 Material-ui 从版本 4.11 升级到版本 5,但面临主题问题
import { createTheme } from '@mui/material/styles';
import {
ThemeProvider,
StyledEngineProvider,
} from '@mui/material/styles';
const theme = createTheme({
...custom themes
});
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>
</StyledEngineProvider>
Inside the app
scenario 1
import { makeStyles } from "@mui/styles";
scenario 2
import { makeStyles } from "@material-ui/core";
const useStyles = makeStyles((theme)=>{
console.log("theme ",theme)
return ({
...my themes
})
}
Run Code Online (Sandbox Code Playgroud)
如果是 mui/styles,控制台会在场景 1 中显示一个空对象,而在使用 Material-ui 的场景 2 中则有主题对象可用
我无法以起始索引 1 初始化数组。我使用了插入附加,并且我希望索引以 1 而不是 0 开头:
n=int(input('enter '))
array=[]
for i in range(1,n+1):
print(i)
element=int(input('element '))
array.insert(i,element)
#array.append(element)
print(i,array[i])
Run Code Online (Sandbox Code Playgroud)
这给出了一个IndexError例外print(i,array[i]):list index out of range.