DotVVM DataPager not working -
dothtml table datapager:
<bp:gridview datasource="{value: userrolegrouplistdtos}" class="table table-bordered table-hover datatable"> <columns> <%--<dot:gridviewtextcolumn valuebinding="{value: name}" headertext="název" events.click="{command: gotodetail() }"/>--%> <bp:gridviewtemplatecolumn headertext="{resource: ecentre.common.resources.admin.common.name}"> <dot:routelink text="{value: name}" routename="userrolegroupdetail" param-id="{value: id}" /> </bp:gridviewtemplatecolumn> <bp:gridviewcheckboxcolumn valuebinding="{value: isblocked}" headertext="{resource: ecentre.common.resources.admin.common.forbidden}" iseditable="true"/> <bp:gridviewtemplatecolumn headertext="{resource: ecentre.common.resources.admin.common.delete}" cssclass="align center"> <%--<i class="glyphicon glyphicon-remove remove-from-list" style="color:red;"> </i>--%> <dot:button class="btn btn-default" click="{command: _parent.deleteuserrolegroup(id)}" text="{resource: ecentre.common.resources.admin.common.delete}"/> </bp:gridviewtemplatecolumn> </columns> </bp:gridview> <bp:datapager dataset="{value: userrolegrouplistdtos}"/>
viewmodel , init in function prerender:
public gridviewdataset<userrolegrouplistdto> userrolegrouplistdtos { get; set; } private readonly iuserrolegroupfacade userrolegroupdetailfacade; private readonly userrolegroupcrudfacade crudfacade; public userrolegrouplistviewmodel(iuserrolegroupfacade userrolegroupdetailfacade, userrolegroupcrudfacade crudfacade) { this.userrolegroupdetailfacade = userrolegroupdetailfacade; this.crudfacade = crudfacade; } public override task init() { return base.init(); } public override task prerender() { userrolegrouplistdtos = new gridviewdataset<userrolegrouplistdto>(); userrolegrouplistdtos.pagingoptions.pagesize = 10; userrolegrouplistdtos.sortingoptions.sortdescending = true; userrolegrouplistdtos.sortingoptions.sortexpression = nameof(userrolegrouplistdto.name); userrolegrouplistdtos.onloadingdata = options => task.run(() => userrolegroupdetailfacade.getuserrolegroupgridviewdatasetloadeddata(options)).result; return base.prerender(); }
pager show, after click on button, nothing happening.
if add initialization init method, pager works, viewmodel has errors.
as tomas wrote, create new instance of dataset, lose pagingoptions.
you have init dataset in new request, not in postbacks.
public override task init() { if (!context.ispostback) { userrolegrouplistdtos = new gridviewdataset<userrolegrouplistdto> { pagingoptions = { pagesize = 10 }, sortingoptions = { sortdescending = true, sortexpression = nameof(userrolegrouplistdto.name) }, }; } return base.init(); }
then have setup delagate onloadingdata in load or prerender
public override task prerender() { userrolegrouplistdtos.onloadingdata = options => task.run(() => userrolegroupdetailfacade.getuserrolegroupgridviewdatasetloadeddata(options)).result; return base.prerender(); }
Comments
Post a Comment