我如何使用reactjs从Webapi以网格形式获取数据?

时间:2019-01-31 04:13:39

标签: reactjs asp.net-web-api

如何使用Reactjs从WebApi以网格形式获取数据?我能够以表格形式显示,但不能以Grid形式显示。它无法通过从WebApi提取来显示我的数据。从createColumnDefs方法中,并不是从api.createRowData中获取我的数据。

createColumnDefs()
{ 
return [
    {headerName: "Id", field: "id"},
    {headerName: "FirstName", field: "firstname"},
    {headerName: "LastName", field: "lastname"},
    {headerName: "UserName", field: "username"},
    {headerName: "Password", field: "password"},
    {headerName: "Address", field: "address"},
    {headerName: "Contact", field: "contact"},
    {headerName: "ExamCountry", field: "examcountry"},
    {headerName: "ExamState", field: "examstate"},
    {headerName: "ExamCity", field: "examcity"},
    //{headerName: "Action", field: "action"},
]}
createRowData()
{ 
    return[
       {id:Users.id,
        firstname:Users.firstname,
        lastname:Users.lastname,
        username:Users.username,
        password:Users.password,
        address:Users.address,
        contact:Users.contact,
        examCountry:Users.examCountry,
        examState:Users.examState,
        examCity:Users.examCity
       }
    ]
}
render()
{
    return(
        <div>
            <h2>All Users</h2>
            <AgGridReact
               columnDefs={this.state.columnDefs}
                rowData={this.state.rowData}
                onGridReady={this.onGridReady}>
            </AgGridReact>
        </div>
    )

0 个答案:

没有答案