小编ash*_*102的帖子

排序不适用于 MUI 数据网格:数据网格 sortComparator 给出未定义

我正在尝试使用数据网格中的嵌套值对数据进行排序,但在数据网格列的 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 列数据

javascript reactjs material-ui

4
推荐指数
1
解决办法
5707
查看次数

event.which is undefined in react

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 …

javascript reactjs material-ui

3
推荐指数
1
解决办法
403
查看次数

与 @material-ui/core 相比,@mui/styles 的 makeStyles 中的主题为空

我正在尝试将 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 中则有主题对象可用

javascript themes reactjs material-ui

1
推荐指数
1
解决办法
2238
查看次数

从 1 而不是 0 开始索引

我无法以起始索引 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.

python index-error

-1
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×3

material-ui ×3

reactjs ×3

index-error ×1

python ×1

themes ×1