Rafael P Posted October 21, 2020 Share Posted October 21, 2020 Hi Everyone! Is there any way to prevent DBGrid from go to the first page of data after refreshing? I mean, if i have 1/4 pages, everytime i delete some row from the page 3 automatically go to the first page (1/4). Then i want to remain in the same page after delete some row of my grid. Any propertie that i have to change or code in this case? Thanks! Link to comment Share on other sites More sharing options...
Sherzod Posted October 21, 2020 Share Posted October 21, 2020 5 hours ago, Rafael P said: Is there any way to prevent DBGrid from go to the first page of data after refreshing? Hello, What do you mean by saying "after refreshing"? 1 Link to comment Share on other sites More sharing options...
Rafael P Posted October 21, 2020 Author Share Posted October 21, 2020 Hello Sherzod. After delete some data, the Grid Refresh to the first page. I will attach some example bellow. Actually i'm trying to refresh the label of Grid down below. I mean, when i delete some data, automatically the grid refresh and go to the first page, and the label down the screen keeps remain the last page. I will attach the code that i using too in the DbGrid -> ExtEvents -> Store.load. I'm following these tips from Mhmda and unfortunatelly i have found these problem. Link to comment Share on other sites More sharing options...
Sherzod Posted October 21, 2020 Share Posted October 21, 2020 7 minutes ago, Rafael P said: After delete some data, the Grid Refresh to the first page. Hello Rafael, Please make a complete testcase to check. Link to comment Share on other sites More sharing options...
Rafael P Posted October 21, 2020 Author Share Posted October 21, 2020 Ok, i will. Thank you so much! 1 Link to comment Share on other sites More sharing options...
Rafael P Posted October 21, 2020 Author Share Posted October 21, 2020 59 minutes ago, Sherzod said: Hello Rafael, Please make a complete testcase to check. Here. I will add the gif too. Try to look at the couting page in example and you will see what i'm trying to explain. DBListGrid.rar Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2020 Share Posted October 22, 2020 10 hours ago, Rafael P said: Here. I will add the gif too. Try to look at the couting page in example and you will see what i'm trying to explain. Hello Rafael, Try with these changes: 1. UnimDBListGrid1 -> ClientEvents -> UniEvents -> function afterCreate(sender) { sender._updateSlider = function(grid) { grid.getDockedItems()[0].hide(); var slider = grid.down('slider'); var lbl = MainmForm.lblPaging; lbl.setHtml('Page: ' + (slider.getValue() + 1).toString() + '/' + (slider.getMaxValue() + 1).toString()); }; } 2. UnimDBListGrid1 -> ClientEvents -> ExtEvents -> function store.load(sender, records, successful, operation, eOpts) { } 3. UnimDBListGrid1 -> OnAfterLoad -> procedure TMainmForm.UnimDBListGrid1AfterLoad(Sender: TUniCustomDBGrid); begin with (Sender as TUnimDBListGrid) do JSInterface.JSCall('_updateSlider', [JSControl]); end; Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 5 hours ago, Sherzod said: Hello Rafael, Try with these changes: 1. UnimDBListGrid1 -> ClientEvents -> UniEvents -> function afterCreate(sender) { sender._updateSlider = function(grid) { grid.getDockedItems()[0].hide(); var slider = grid.down('slider'); var lbl = MainmForm.lblPaging; lbl.setHtml('Page: ' + (slider.getValue() + 1).toString() + '/' + (slider.getMaxValue() + 1).toString()); }; } 2. UnimDBListGrid1 -> ClientEvents -> ExtEvents -> function store.load(sender, records, successful, operation, eOpts) { } 3. UnimDBListGrid1 -> OnAfterLoad -> procedure TMainmForm.UnimDBListGrid1AfterLoad(Sender: TUniCustomDBGrid); begin with (Sender as TUnimDBListGrid) do JSInterface.JSCall('_updateSlider', [JSControl]); end; Hi Sherzod. Unfortunately, UnimDbListGrid don't have AfterLoad Event. Only these options: Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 I'm using V. 1.90.0.1535 Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2020 Share Posted October 22, 2020 4 minutes ago, Rafael P said: Unfortunately, UnimDbListGrid don't have AfterLoad Event. Only these options: Hi Rafael, Aren't you going to upgrade to the latest build yet? Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 Sorry, no. But i will, and as soon as i get i'll test. Thanks anyway!! Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2020 Share Posted October 22, 2020 8 minutes ago, Rafael P said: Sorry, no. But i will, and as soon as i get i'll test. Thanks anyway!! Thanks. Also I will try to give you another solution... Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 10 minutes ago, Sherzod said: Thanks. Also I will try to give you another solution... Thank you so much, and sorry to bother you! Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2020 Share Posted October 22, 2020 Just now, Rafael P said: Thank you so much, and sorry to bother you! OK, no problem. Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2020 Share Posted October 22, 2020 43 minutes ago, Rafael P said: I'm using V. 1.90.0.1535 1. function afterCreate(sender) { sender._updateSlider = function(grid) { grid.getDockedItems()[0].hide(); var slider = grid.down('slider'); var lbl = MainmForm.lblPaging; lbl.setHtml('Page: ' + (slider.getValue() + 1).toString() + '/' + (slider.getMaxValue() + 1).toString()); }; } 2. function store.load(sender, records, successful, operation, eOpts) { ajaxRequest(sender.grid, '_afterload', []); } 3. procedure TMainmForm.UnimDBListGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_afterload' then with (Sender as TUnimDBListGrid) do JSInterface.JSCall('_updateSlider', [JSControl]); end; Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 13 minutes ago, Sherzod said: 1. function afterCreate(sender) { sender._updateSlider = function(grid) { grid.getDockedItems()[0].hide(); var slider = grid.down('slider'); var lbl = MainmForm.lblPaging; lbl.setHtml('Page: ' + (slider.getValue() + 1).toString() + '/' + (slider.getMaxValue() + 1).toString()); }; } 2. function store.load(sender, records, successful, operation, eOpts) { ajaxRequest(sender.grid, '_afterload', []); } 3. procedure TMainmForm.UnimDBListGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_afterload' then with (Sender as TUnimDBListGrid) do JSInterface.JSCall('_updateSlider', [JSControl]); end; Once i have start the application using your code, the screen has appear only in Loading mode... Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2020 Share Posted October 22, 2020 1 hour ago, Rafael P said: UnimDBListGrid1 -> ClientEvents ? Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 Here's my complete testcase with your codes, so you can verify better. Thank you! DBListGrid.rar Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 Ops, i have found, it's my mistake, sorry! Link to comment Share on other sites More sharing options...
Rafael P Posted October 22, 2020 Author Share Posted October 22, 2020 Works great, thank you Sherzod! 1 Link to comment Share on other sites More sharing options...
Recommended Posts