Hi
I am trying to create a custom page template for my GridComponents. However, the pageSettings template only takes in string or HTML. Is there any way for the template prop to take in JSX component instead?
And also able to all the pageSettings like currentPage, totalPages and totalRecordCount without the use of bind method
Hi Praveen
Please refer to the message below and codesandbox for example:
Defines the template which renders customized elements in pager instead of default elements. It accepts either template string or HTML element ID.
@default
Other than able to use JSX components in the template prop, the JSX component should be able to take in GridComponent ref to get information for PageSettings (currentPage, totalPages and totalRecordCount)
https://codesandbox.io/s/mutable-dawn-7jy4c?file=/src/App.tsx
Thanks
Hi Ajith G
Is there any update on this issue?
Regards
Yu Feng
|
function Home() {
const sortSettings:SortSettingsModel = { columns: [
{field: 'EmployeeID', direction: 'Ascending' }
] };
const filterOptions: FilterSettingsModel = {
type: 'Excel'
};
const template = (pagerData: any) => {
return (
<div className="e-pagertemplate">
<div className="col-lg-12 control-section">
<div className="content-wrapper">
<NumericTextBoxComponent min={1} max={3} value={pagerData.currentPage} format='###.##' change={change} />
</div>
</div>
<div
id="totalPages"
className="e-pagertemplatemessage" style={{ marginTop: 8, marginLeft: 30, border: "none", display: "inline-block"}}>
<span className="e-pagenomsg">
{pagerData.currentPage} of {pagerData.totalPages} pages ({pagerData.totalRecordsCount} items)
</span>
</div>
</div>
);
}
const change = (args:any) => {
const grid = (document.getElementById('FGrid') as any).ej2_instances[0];
grid.goToPage(args.value);
}
const pageSettings:any = { template, pageSize: 3 };
return(<div> <p>Grid-1 using Functional Components</p>
<GridComponent dataSource={sdata} id="FGrid" allowPaging={true} allowFiltering={true} pageSettings={ pageSettings }
allowSorting={true} filterSettings={filterOptions} sortSettings={ sortSettings }>
<ColumnsDirective>
<ColumnDirective field='OrderID' width='100' textAlign="Right"/>
<ColumnDirective field='CustomerID' width='100'/>
<ColumnDirective field='EmployeeID' width='100' textAlign="Right"/>
<ColumnDirective field='Freight' width='100' format="C2" textAlign="Right"/>
<ColumnDirective field='ShipCountry' width='100'/>
</ColumnsDirective>
<Inject services={[Page, Sort, Filter, Group]} />
</GridComponent>
</div>
)
}
|
Hi Rajapandi
I tested on the zip that you sent me is working fine which the packages are based on the old versions. However, it seems that it does not render on the latest version of the Syncfusion/React.
I have updated the codesandbox with the latest packages and it does not render as it is. Please refer to the link below:
https://codesandbox.io/s/mutable-dawn-7jy4c?file=/src/App.tsx
Regards
Yu
|
App.tsx
const dataBound = () => {
var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0];
grid.pagerModule.isInitialRender = false;
grid.pagerModule.renderReactPagerTemplate();
}; |