Get ag-grid page which is clicked - pagination

In ag-grid pagination, I need catch the page where I am clicking. I do not want the current page, this is the origin, I need the destiny.
For instance:
Pagination: << < Page 4 of 15 > >>
When click << the result must be 1.
When click < the result must be 3.
_
When click > the result must be 5.
When click >> the result must be 15.
paginationChanged(params) {
// Something like:
// params.paginationGetCurrentPage();
},

Related

How to expand a combobox/listbox to select an option by its span text value? I have working code to select the option but the combobox cannot expand

I am trying to expand a combobox/listbox in a website. If i work off the console for the website and use
let countylocation = 'Cook County - Municipal Civil - District 2 - Skokie';
await page.evaluate((countylocation) => {
Array.from(document.querySelectorAll('span')).filter(li => {
return li.innerText == countylocation
}).forEach(element => {
if (element) element.click(); // click on il with specific text
});
}, countylocation);
This works perfectly to select that option, but i have to physically click on the list box first, so that it expands, and allows me to select any of the span/text options.
What i have noticed before clicking on it is:
Once its clicked, its aria attributes change to:
What i have tried doing was
await page.evaluate(() => {document.querySelector("body > ngb-modal-window > div > div > app-case-search-filter-modal > div > form > div.modal-body > div > div > app-searchable-dropdown-field > div > div.form-group.ng-pristine.ng-invalid.ng-touched > div > span > ng-select > div > div > div.ng-input").click() });
But that yields an "undefined" error. It seems that this listbox can only be physically clicked and not programmatically.
I have also tried to expand its attribute of aria-expanded = true, but it still gives me back an undefined error.
document.querySelector("body > ngb-modal-window > div > div > app-case-search-filter-modal > div > form > div.modal-body > div > div > app-searchable-dropdown-field > div > div.form-group.ng-pristine.ng-invalid.ng-touched > div > span > ng-select > div > div > div.ng-input").setAttribute('aria-expanded', 'true');
Is there some other way to expand this list box so i can choose the options within?
If for whatever reason when you try clicking and it doesn't work what you can do is use page.type into that textbox location so you can trick the website into expanding the drop down box. Once that happens, the code you posted to find the selection in "countylocation" should work.
Like this
var countylocation = 'Cook County - Municipal Civil - District 2 - Skokie'
await page.type(the_selector_here, countylocation);
await page.waitFor(2000) //just in case
await page.evaluate((countylocation) => {
Array.from(document.querySelectorAll('span')).filter(li => {
return li.innerText == countylocation
}).forEach(element => {
if (element) element.click(); // click on il with specific text
});
}, countylocation);
Basically this will emulate as if a user is starting to type the location and then the drop box appears to show you the choice you're trying to make and then you click on it.

How synchronize two list controls vertically in MFC

I have two list controls and both are vertically scroll-able separately.
However I want to synchronize scroll also I would like to hide the vertical scroll bar in list control-1.
On the other hand if you scroll vertically list control-2, then the list control-1 should scroll down automatically the same amount of items in such way that the options on the both the list boxes should always appear in the same row.
How can I achieve this in MFC?
I do this with a connection between two list views through the document, but the end result is a command to the Scroll member of the slave list control.
So handle the ON_WM_VSCROLL() in the master, I actually have a custom notify but you may want to just shortcut to from the likes of in the master:
if( pS->nSBCode == SB_THUMBTRACK )
GetDocument( )->SetSplitScrollPos( pS->nPos );
How ever you work past to the likes of 'SetSplitScrollPos' it ends up with this at the slave:
void CLCtrl::ScrollToVPosition( long inPos )
{
long scroll= ( inPos - curVScrollPos );
Scroll( scroll << 20 );
curVScrollPos= inPos;
}
The 'Scroll' call is a CListCtrl member, so you could:
mySlaveCtrl.Scroll( ... );
Now, I'm sorry, but I don't recall why the shift of 20 as '<< 16' should move the value to the hi_word, but it needed to be 16 times greater, (20 - 16). I did not write in the required comments.
To wit, it may be as simple for you to handle the master ON_WM_VSCROLL and:
if( pS->nSBCode == SB_THUMBTRACK )
mySlaveCtrl.Scroll( ( ps->pos - curVScrollPos ) << 20 );

Active Admin pagination

Active Admin's pagination on index pages is great, but we are trying to allow the user to type in the desired page number (in addition to the clickable page buttons).
Their desire is to have a prompt like "Enter Page Number:" and an input box where they can type in the desired page number.
Anyone done this already, or have ideas on how to proceed?
You can create a custom sidebar section like this:
sidebar :jump_to_page do
input :page_number
input type: :submit
end
Then add this to you active_admin.js.coffee file:
$ ->
$("#page_number_submit").on 'click', (e) ->
page_number = $("#page_number").val()
if window.location.search.indexOf("page=") > 0
window.location.search = window.location.search.replace(/page=\d*/, "page=#{page_number}")
else if window.location.search.indexOf("?") == 0
window.location.search = window.location.search + "&page=#{page_number}"
else
window.location.search = "page=#{page_number}"

jqPagination requests for new page

I have a large db table that I want to show to users. I show the info in a table, about 30 rows per page. I want to use jqPagination to allow the users to jump to a different page. So page 1 will show rows 1-30, page 2 will show rows 31-60,... The only example I see are showing how to use it to jump to different section of a page. Is it possible to use jqPagination in a way to request the next 30 rows to a new page?
Thanks in advance!
If you're displaying all table rows to begin with you could use the following code to only show 30 at a time:
$(document).ready(function() {
// select the table rows
$table_rows = $('.table-example tbody tr');
var table_row_limit = 30;
var page_table = function(page) {
// calculate the offset and limit values
var offset = (page - 1) * table_row_limit,
limit = page * table_row_limit;
// hide all table rows
$table_rows.hide();
// show only the n rows
$table_rows.slice(offset, limit).show();
}
$('.pagination').jqPagination({
max_page: $table_rows.length / table_row_limit,
paged: page_table
});
// set the initial table state to page 1
page_table(1);
});
Table pagination example.
If you don't display all rows to begin with, you could adapt this code to fetch the rows from your system using AJAX instead of showing / hiding.

Removing menu in MFC

In MFC how to remove a menu-item of POPUP type. RemoveMenu() either take ID or position. Since, there is no ID for POPUP menu, option left is by using position.
But I am not getting how and where I can call RemoveMenu().
File Edit Test
Test_submenu_1
Test_submenu_2
Test_submenu_3 > submenu_3_item_1
Test_submenu_4
Test_submenu_5
I want to remove Test_submenu_3? I am not getting how do find CMenu object for Test so that I can call RemoveMenu() by passing position "2" for submenu_3_item_1.
Any suggestion for doing this will be greatly appreciated.
Thanks!
You cannot use LoadMenu, since this function does just that.
After modifying loaded menu it is killed when menu object used to load it goes out of scope. You have to modify menu that is currently used.
Your menu is a popup part of the main menu, second in position. It contains 5 items and second one is another popup. To my understanding, you want to remove this item and popup of this item.
To make it work you will have to ask main window for the current menu:
CMenu* pMenu = GetMenu(); // get the main menu
CMenu* pPopupMenu = pMenu->GetSubMenu(2);//(Test menu with item....)
pPopupMenu->RemoveMenu(2, MF_BYPOSITION);
Of course, this code is from the main frame. If you want to use it elsewhere, you will have to access all using pointer to the main frame.
Try the below. You get the Test sub-menu first (index 2), then once you have that you tell it to remove its Test_submenu_3 submenu by position (also 2).
CMenu topMenu;
topMenu.LoadMenu(IDR_YOUR_MENU);
CMenu& testSubMenu = *topMenu.GetSubMenu(2);
testSubMenu.RemoveMenu(2,MF_BYPOSITION);
'Test' is the 3rd menu item (by position) on the top level menu. It's just been rendered horizontally rather than vertically. Assuming you have a handle to the top level menu use the same code you'd use to the get the sub menus as you would to get the 'Test' menu.
You can use this below code to remove the submenu, by comparing name
bool RemoveSubmenu(CMenu * pMenu) {
for (int pos = 0; pos < pMenu->GetMenuItemCount(); pos++) {
wchar_t *name = new wchar_t[mf.cch + 1];
MENUITEMINFO mf;
ZeroMemory(&mf, sizeof(mf));
mf.cbSize = sizeof(mf);
mf.fMask = MIIM_SUBMENU | MIIM_FTYPE | MIIM_STRING;
mf.fType = MIIM_STRING;
mf.dwTypeData = NULL;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf))
break;
if (mf.hSubMenu != NULL){
mf.fMask = MIIM_TYPE;
mf.fType = MFT_STRING;
++mf.cch;
mf.dwTypeData = (LPSTR)name;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf)){
bRet = false;
break;
}
//
// compare sub menu name (i.e mf.dwTypeData) here, do the required
// modifications
//
pMenu->RemoveMenu(pos, MF_BYPOSITION);
bRet = true;
break;
}
}
}

Resources