Ionic 4. How refresh or update page in super-tab - ionic4

I have a "ParentPage" page with supertabs:
<super-tabs-toolbar slot="top">
<super-tab-button>
<ion-label>ChildPage 1</ion-label>
</super-tab-button>
<super-tab-button>
<ion-label>ChildPage 2</ion-label>
</super-tab-button>
</super-tabs-toolbar>
<super-tabs-container>
<super-tab>
<ion-nav [root]="childPage1"></ion-nav>
</super-tab>
<super-tab>
<ion-nav [root]="childPage2"></ion-nav>
</super-tab>
</super-tabs-container>
</super-tabs>
From the "ParentPage" page I modify the data of "childPage1", but "childPage1" is not updated visually, and the data is updated.

Related

How to code a simple algorithm to fetch list of data through pagination in a fresh new application?

I'm making a clone of social app. I'm using graphQL as my backend. My problem is that every time I query a list of data it is returning the same result. When I will release that app, the user base will be very small so the amount or data is less in number. So I'm facing the issue described below:
1. My data in data base is like:
I'd=1 title=hello1
I'd=2 title=hello2
I'd=3 title=hello3
2. When I'm querying data through pagination with limit=3, I'm getting list of items is like:
Query 1
I'd=1 title=hello1
I'd=2 title=hello2
I'd=3 title=hello3
3. When I'm adding new items to data base, it is invoked in between the items like below:
I'd=1 title=hello1
I'd=4 title=hello4
I'd=2 title=hello2
I'd=3 title=hello3
I'd=5 title=hello5
4. So next fresh query result(limit=3) Will be like:
Query 2
I'd=1 title=hello1
I'd=4 title=hello4
I'd=2 title=hello2
Look at the data set previously our query result was: I'd=1,2 & 3 now I'd=1,4 & 2 so the user will get same result as id=1,2 is in new list.
If I will save pagination nextToken/cursor(I'd=3) of first query(query 1) then after new data added to data base the new query will start from I'd=5, because it is present after I'd=3. Look at the new dataset it will miss I'd=4 because nextToken is saved for I'd=3 for the query will start from I'd=5. Hope you can understand.
If your suggestion is add a sort key of created at, I want say that if I will add some filter, the data set will become so much selective that might become the reason of limited number of data in feed and we know a feed should query unlimited data.

fnupdate updates wrong row datatables

I am trying to update a row by passing index.
http://live.datatables.net/raculubo/1/
But it most of the time replaces a wrong row.
The code is :-
$(document).ready(function() {
var table = $('#example').DataTable();
var index = table.column(0).data().indexOf("Cedric Kelly");
console.log("index2",index);
table.row().data(["ax","by","dd"], index);
} );
This is happening because of how you are sorting your data, leading to a difference between the "sort order" index and the "internal DataTables" index.
The table.column(0).data() function will return an array of names, as currently displayed in the table, taking into account sorting. In this scenario, the index of "Cedric Kelly" is therefore 1.
However, the internal unique index value stored by DataTables is actually 3 because that is the order provided to DataTables from your HTML code when the data was loaded for the very first time (where Cedric Kelly is the 4th record listed - so the index is 3).
This initial loading happens before data is sorted, and it is during this step that data indexes are assigned. Once assigned, they never change (unless you delete data).
Your data update function uses the value of 1 - thus updating the wrong row.
The fix for this is to tell DataTables to use the original loading order in the table.column(0).data() function:
var index = table.column(0, {order:'index'} ).data().indexOf("Cedric Kelly");
That directive {order:'index'} causes DataTables to use the original loading order. Now, the correct record will be updated because this index will now return 3 instead of 1.
You can see more details about this "selector modifier" syntax here.
Bear in mind that the correct syntax for updating a row is actually this:
table.row( index ).data(["ax","by","dd"]);
Finally, bear in mind that if you filter your data, then you are OK, since the default value used is search: 'none' - which means "do not take searching/filtering into account" when selecting the column data.

Duplicate transaction entries on setCurrentOrderState in prestashop 1.6.1.18

I have latest 1.6 version (1.6.1.18).
Problem.
1. Order is created
2. Payment module redirects user
3. On success order state is changed
These lines cause problem
echo $order->getOrderPaymentCollection()->count(); // returns 1
$history = new OrderHistory();
$history->id_order = $order->id;
$history->changeIdOrderState($stateId, $order->id);
echo $order->getOrderPaymentCollection()->count(); // returns 2
Other method
echo $order->getOrderPaymentCollection()->count(); // returns 1
$order->setCurrentState($orderId);
echo $order->getOrderPaymentCollection()->count(); // returns 2
Here is similar problem, but with another module https://github.com/ICEPAY/Prestashop/issues/1
setCurrentState created duplicate entries for transactions.
How to avoid this?
Can I change state and update transaction history at once without duplicate entries?
Upon installation no settings of the shop have been changed.
I have the same problem. To avoid payment duplicate change:
$history->changeIdOrderState($stateId, $order->id);
to
$history->changeIdOrderState($stateId, $order->id, true);
Third parameter 'true' means use existing payment. Lost half day with this problem, then just try to dig in prestashop github source and found this third parameter.

CRM 2011 - Dashboards Slide Show For on a TV

My customer want to have a "Slide Show" of all the "Dashboards" that are in the CRM. He wants to be able to hang a TV out and then show a slide with some "Dashboards" that will change every 10 seconds. The data needs to be up to date, so taking screenshots and putting them in a Powerpoint isn't enough. I was thinking about the following :
Create a custom Page with an Iframe and update the iframe every 10 seconds with a new "Dashboard" in it. I know you can do the following => /OrganizationName/dashboards/dashboard.aspx?dashboardId=%7b16a69a12-105a-e011-bd7f-000c29198df7%7d&dashboardType=1030&pagemode=iframe, but there is no way where I can find the ID. "The Copy A Link" functionality when "Right"-clicking on a view isn't there anymore.
I remember at the "Tech Days" of CRM, that there was a possiblity to immediatly connect to the "Report"-server for showing the "Dashboards"... Or is there a table in the "Database" who has all the "Names" + "IDs" of the dashboards?? I can't seem to find it in the Database...
How would you guys make a cool "Dashboard"-slid for on TV (PC connected to TV is what I mean by that).
I have a few screens in my office building showing dashboards from CRM, mainly Service Desk/call centre statistics.
I used this 'copy link' method to obtain a URL to the full screen dashboard (without any sidebars) then I installed a plugin/extension for IE to auto-refresh and cycle through various dashboard tabs (can't remember what it's called, but if you Google I'm sure you'll find it). This is always up to date and creates a slideshow effect.
System Dashboards are System Forms and Personal Dashboards are User Forms so it cab be retrieved from dbo.SystemFormBase and dbo.UserFormBase tables respectively.
If any Personal dashboard is shared then that details can be retrieved from PrincipalObjectAccess table.
Use below sp to retrieve dashboard id, name and type for the specific user.
Create PROCEDURE [dbo].[GetDashboardIds]
(
#SystemUserID uniqueidentifier
)
AS
BEGIN
select FormId as 'DashboardID',Name as 'Name', 'System' as DashboardType
from dbo.SystemFormBase
where Type = 0
Union
select UserFormId as 'DashboardID',Name as 'Name', 'Custom' as DashboardType
from dbo.UserFormBase
where Type = 0 and OwnerId = #systemUserID
union
select UserFormId as 'DashboardID',Name as 'Name', 'Custom' as DashboardType
from dbo.UserFormBase UFB inner join PrincipalObjectAccess POA on UFB.UserFormId = ObjectId
where Type = 0 and POA.PrincipalId = #systemUserID
end
Happy Coding

jqGrid/NHibernate/SQL: navigate to selected record

I use jqGrid to display data which is retrieved using NHibernate. jqGrid does paging for me, I just tell NHibernate to get "count" rows starting from "n".
Also, I would like to highlight specific record. For example, in list of employees I'd like a specific employee (id) to be shown and pre-selected in table.
The problem is that this employee may be on non-current page. E.g. I display 20 rows from 0, but "highlighted" employee is #25 and is on second page.
It is possible to pass initial page to jqGrid, so, if I somehow use NHibernate to find what page the "highlighted" employee is on, it will just navigate to that page and then I'll use .setSelection(id) method of jqGrid.
So, the problem is narrowed down to this one: given specific search query like the one below, how do I tell NHibernate to calculate the page where the "highlighted" employee is?
A sample query (simplified):
var query = Session.CreateCriteria<T>();
foreach (var sr in request.SearchFields)
query = query.Add(Expression.Like(sr.Key, "%" + sr.Value + "%"));
query.SetFirstResult((request.Page - 1) * request.Rows)
query.SetMaxResults(request.Rows)
Here, I need to alter (calculate) request.Page so that it points to the page where request.SelectedId is.
Also, one interesting thing is, if sort order is not defined, will I get the same results when I run the search query twice? I'd say that SQL Server may optimize query because order is not defined... in which case I'll only get predictable result if I pull ALL query data once, and then will programmatically in C# slice the specified portion of query results - so that no second query occur. But it will be much slower, of course.
Or, is there another way?
Pretty sure you'd have to figure out the page with another query. This would surely require you to define the column to order by. You'll need to get the order by and restriction working together to count the rows before that particular id. Once you have the number of rows before your id, you can figure what page you need to select and perform the usual paging query.
OK, so currently I do this:
var iquery = GetPagedCriteria<T>(request, true)
.SetProjection(Projections.Property("Id"));
var ids = iquery.List<Guid>();
var index = ids.IndexOf(new Guid(request.SelectedId));
if (index >= 0)
request.Page = index / request.Rows + 1;
and in jqGrid setup options
url: "${Url.Href<MyController>(c => c.JsonIndex(null))}?_SelectedId=${Id}",
// remove _SelectedId from url once loaded because we only need to find its page once
gridComplete: function() {
$("#grid").setGridParam({url: "${Url.Href<MyController>(c => c.JsonIndex(null))}"});
},
loadComplete: function() {
$("#grid").setSelection("${Id}");
}
That is, in request I lookup for index of id and set page if found (jqGrid even understands to display the appropriate page number in the pager because I return the page number to in in json data). In grid setup, I setup url to include the lookup id first, but after grid is loaded I remove it from url so that prev/next buttons work. However I always try to highlight the selected id in the grid.
And of course I always use sorting or the method won't work.
One problem still exists is that I pull all ids from db which is a bit of performance hit. If someone can tell how to find index of the id in the filtered/sorted query I'd accept the answer (since that's the real problem); if no then I'll accept my own answer ;-)
UPDATE: hm, if I sort by id initially I'll be able to use the technique like "SELECT COUNT(*) ... WHERE id < selectedid". This will eliminate the "pull ids" problem... but I'd like to sort by name initially, anyway.
UPDATE: after implemented, I've found a neat side-effect of this technique... when sorting, the active/selected item is preserved ;-) This works if _SelectedId is reset only when page is changed, not when grid is loaded.
UPDATE: here's sources that include the above technique: http://sprokhorenko.blogspot.com/2010/01/jqgrid-mvc-new-version-sources.html