dgrid pagination example - dojo

Can anyone point me to an example of using the Pagination extension of dgrid with a dgrid? This could be a reference link or a simple example you type up. I've defined it in my code, used it with an OnDemandGrid where it is added to the declare mixin for my custom grid. I see arrows for page navigation, I see the page size setting menu, but my specification of rowsPerPage: 3 does nothing. I still see my 7 sample records.
I'm using a modified Cache (data object store) that wraps a JsonRest and Memory store for my dgrid.

I think the issue is that you can't use OnDemandGrid with pagination since the OnDemandGrid has it's own internal virtual paging logic. From the dgrid extensions wiki:
In contrast to the OnDemandList and OnDemandGrid modules, the
Pagination extension implements classic discrete paging controls. It
displays a certain number of results at a given time, and provides a
footer area with controls to switch between pages.
Note: the Pagination extension should be mixed into List or Grid, not
one of the OnDemand constructors, since those contain their own
virtual scrolling logic. Internally, Pagination inherits from the same
_StoreMixin module inherited by the OnDemand prototypes for common integration with dojo/store.
What you want to do instead is mixin Pagination into a plain Grid. The Pagination Mixin includes the properties you're interested in such as number of rows. The Paginator extension handles talking to the provided store for retrieving and rendering the set of rows to display. A define for a class like that might look like:
define(['dojo/_base/declare','dgrid/Grid', 'dgrid/extensions/Pagination'],function(declare,Grid,Pagination){
return declare('mine.PaginatedGrid',[Grid,Pagination],{
//various default you can set
pagingLinks: false,
pagingTextBox: true,
firstLastArrows: true,
minRowsPerPage: 5,
rowsPerPage: 5,
pageSizeOptions: [5, 10, 15, 25, 50, 100]
});
});

The best examples of DGrid and its extensions can be found in the test folder of the DGrid project. They can be found here:
DGrid Tests
Specifically the Paginations Tests can be found:
Here,
here,
and here
To run them:
Clone the git repo
Drop it on your webserver
Navigate to the html page

Related

Does the windowClass property or NgbModalOptions actually do anything?

I am opening an NgbModal passing a TemplateRef to create the dialog body, and passing in a custom class via the windowClass property of the NgbModalOptions object that I pass to the open() method. I define the class in a referenced styleUrl in the component and am serving the modal via an injectable service in the component. The modal is loading fine, and I can see the class name when I inspect the DOM, but the class appears to have no bearing on the modal. I would like to use it to customize the size of the modal (css is defined to affect the child div where the size is set), but I have also played with properties that I can see in the Styles tab of the Chrome dev tools, but cannot see it affecting anything. When I inspect in Firefox dev tools, I can find the CSS as an inline style sheet and it has a reference to the ngContent identifier assigned by Angular, so I am assuming that is does not affect the entire document, nor those parts added by ng-bootstrap that constitute the modal wrapper. Has anyone been able to make this work successfully? I am at my wit's end. I would even be happy if I could get an ElementRef of the modal-header dive, but since I am using a template (which is not fully loaded in the DOM at init time) I have not been able to. One of my requirements is that we do all DOM manipulation via Angular to maintain platform independence in the project ... so no jQuery. Any thoughts? And thanks in advance!!
I use windowClass and size attributes of NgbModalOptions to customize the modal. Sample code follows:
this.modalService.open(<your_template_ref_var>, {size: 'lg', windowClass: 'modal-adaptive-s1'});
Whereas
.modal-adaptive-s1 .modal-lg {width: 400px !important; max-width: 400px;}

How to inject CSS into webkit?

On Linux I'm creating a webkit window which needs to display a certain URL.
I'm doing that like the following:
GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// Create a browser instance
WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
// Put the browser area into the main window
gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(webView));
// Load a web page into the browser instance
webkit_web_view_load_uri(webView, "http://example.com");
// Make sure that when the browser area becomes visible, it will get mouse
// and keyboard events
gtk_widget_grab_focus(GTK_WIDGET(webView));
// Show the result
gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 600);
gtk_widget_show_all(main_window);
However, I need to inject some CSS into this to hide a certain checkbox.
How do I inject CSS into the DOM.
I see that I can get the dom like
WebKitDOMDocument *dom = webkit_web_view_get_dom_document(webView);
But from here I can't see how to inject the CSS.
It sounds like the webkit_web_view_run_javascript() answer was a good solution to your specific problem, since you only needed to hide one checkbox.
To answer the general problem of how to inject arbitrary CSS: if you're using a recent version of WebKitGTK+, create a WebKitUserContentManager, call webkit_user_content_manager_add_stylesheet(), and then pass the WebKitUserContentManager when creating your WebKitWebView, either using webkit_web_view_new_with_user_content_manager() or by using g_object_new() manually if you need to set multiple construct-only properties.
Unrelated warning: webkit_web_view_get_dom_document() was removed in WebKitGTK+ 2.6. (The DOM API is only accessible via web process extensions nowadays.) You are using an old, insecure version of WebKitGTK+!
Its not clear which Webkit GTK version you are using, however concepts essentially remain same for both versions. For webkit version 2, its slightly more complicated as DOM manipulation is done on extension side.
You need to reach to the desired element - either by id e.webkit-dom-document-get-element-by-id or by name. This will return you instance of WebElement. If you use by name call, please be ware that there could be multiple elements with same name
From here you can either set the style by setting appropriate style attribute webkit_dom_element_set_attribute or other variations that can deal with styles and css rules.
Or you can take easy option and just execute the javascript that does the same thing by calling webkit_web_view_run_javascript

Why does the Dojo API not include all related commands for specific types? (I'll describe better below.)

Just as an example, the "dijit/layout/ContentPane". In my sample code, which I found online and have been manipulating, this appears in the body of the new ContentPane():
new ContentPane({
region: "top",
"class": "edgePanel",
content: "Header content (top)"
})
My question pertains to why the term "region" is never mentioned in the Dojo API for the ContentPane. There are other examples of this, too.
Here is another example:
new ContentPane({
region: "left",
id: "leftCol", "class": "edgePanel",
content: "Sidebar content (left)",
splitter: true
})
"splitter" is never mentioned in the ContentPane API for Dojo. As far as I know, from the API, I would never even know I could specify "splitter: true" for a new ContentPane.
So my final question is: Is there somewhere I can find all types, "region" for example, that pertains to a given function? How would I ever know that I needed to specify using "region: "top"" if I hadn't found this code online?
Thanks guys.
BorderContainer regions can hold various widgets, not just ContentPanes, so documenting them on that specific class isn't ideal. At the same time, these properties only make sense on children of BorderContainers (e.g. not ContentPanes that are not children of BorderContainers).
For this reason, these properties are documented as child widget properties of BorderContainer.
The BorderContainer API docs specifically call out this separate location for documentation on child widget properties:
See BorderContainer.ChildWidgetProperties for details on the properties that can be set on children of a BorderContainer.
Note that there is a similar dedicated page for StackContainer child widget properties (which also applies to TabContainer and AccordionContainer since they extend StackContainer).
The BorderContainer examples in the reference guide also include the region and splitter properties (though they don't particularly explain them).
The Layout with Widgets tutorial explains regions rather thoroughly in its section on BorderContainer.

How to set the default amount of rows in datatables plugin?

Does anyone know the Yet Another DataTables Column Filter (yadcf) js plugin ?
It doesn't have much documentation and I can't figure out how to set the default number of rows to display (it shows 10 rows as default and I want at least 50).
Quick answer: "pageLength": 50 (for 1.10+) or "iDisplayLength": 50 (for 1.9-)
Long one:
You need to distinguish between the datatables plugin and yadcf plugin
The sole purpose of yadcf it to allow the user the ability to easily add various types of filters to the datatables table
This jQuery plug-in allows the user to easily add filter components to table columns, the plug-in works on top of the DataTables jQuery plug-in.
So your current question is not related to the yadcf plugin,
But if you look at the yadcf showcase you can spot that in on of its pages it demonstrate the use of the iDisplayLength attribute (which is the one you need your case)
Look at the page Yet Another DataTables Column Filter - DOM source example, scroll till you see the code snippet used on that page , notice the: "iDisplayLength": 25
p.s I'm the author of yadcf

layout doesn't work when adding nodes to graph dynamically

When I add nodes to the graph statically via the elements property of
$('#cy').cytoscape(..)
the layout option works but when I add them via
cy.add({..})
the layout is ignored. I can apply new layout only on these events(click, mouseover, mouseout) like this:
cy.on('mouseover', function(event) {
cy.layout({name: "grid"});
});
and the layout changes. Tried with other events: ready, done and load but it doesn't work.
Is there a normal way way to change the layout when elements are added dynamically?
You can't call a second layout while the initialisation layout is running. Configure your initialisation properly (http://cytoscape.github.io/cytoscape.js/#core/initialisation) to have all the data and options you require.
As for cy.add(): Don't try using cy.add() on load unless you specify everything you need (incl. position) for those elements. Or, you'll have to at least wait for layoutstop before running a new layout. In general, you're better off using the initialisation options to do things for you rather than having to worry about edge cases and event synchronising yourself.