Is there a hidden method to set the time in Materialize 1.0's timepicker? - materialize

According to the docs, I can programatically set the date for the datepicker like so:
M.Datepicker.getInstance($('form').find(tmpVar)).setDate(new Date());
However, it doesn't list a similar method for the timepicker and setTime() doesn't work.
The method I had in place in the previous version of Materialize has broken in 1.0. Is this a case of it being left out of the docs, or is this something that is simply not possible with this new version?

Related

QTP - Checking dynamic pages

I'm trying to check if a value is contained in the innertext of a webelement but I'm having a little problem: frames seem to change at every refresh of the pages.
These are the steps I've recorded:
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebEdit("pdrBean.pdrPod").Set parameter("POD")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebButton("Cerca").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_2").Image("show_files").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_6").Image("Lente").Click
cctype = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down").GetROProperty("innertext")<br>
DataAct = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down_2").GetROProperty("innertext")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click
The frames "dme2_appl6" and "dme2_appl7" changes at every refresh of the two pages.
The question is simple: how can I rewrite these two actions to make them universal?
I've tried to do something like:
Set objFrame = Frame("title:=dme2_appl_.")
and then
Browser("SystemPage").Page("SystemP").objFrame.Image("Lente").Click
But QTP gives me an error in return: "property or method not supported by the object"
Please try using the below code
Browser("SystemPage").Page("SystemP").Image("Lente").Click
Avoid using the "Frame" and if you really want to use it, put regex for name property of Frame.
Go to Object Properties--> Click on the Frame object --> Mandatory Properties--> Change name property as
like iFrame_213123123 to i.*
Hope this will solve your problem.
I don't think you can use a frame object that way. When you write Page().Frame() UFT sets the frame's parent in different way than if you first create the Frame.
Think of Frame() as a function that behaves differently when called on a Page or as a free function.
Try:
Browser("SystemPage").Page("SystemP").Frame("title:=dme2_appl_.")

Bootstrap DatePicker setDate method not updating calendar

I'm setting the value of a bootstrap datepicker by making use of the setValue method provided.
For example
tripToDatePicker.setValue(tripFromDatePicker.date);
But for some reason the calendar is not updated
'setValue' is replaced by 'setDate'.
Using a string as input for setDate can be tricky. It has to match with the dateformat, else you can get unexpected results. It is more safe to create a 'new Date(y,m,d)' from your input, e.g. new Date(2015,3,10) for '10 Apr 2015'. This will always work.
When using a date representation in seconds, e.g. 1428659901, then use 'new Date(value*1000)'. Note that datepicker will eat any value here, but only show the selected date in the calendar if hours, minutes and seconds are equal to 0. Took me a while to figure that out....
Edit:
http://www.eyecon.ro/bootstrap-datepicker/ is not much documented, you should try http://eternicode.github.io/bootstrap-datepicker/.
anyway the code below will work for you
$("#dp1").datepicker("update", "02-16-2012");
or
$("#dp1").datepicker("setValue", "02-17-2012");
where "#dpi" is the id of the text field on whcih datepicker is used.
After trying many things, I ended up using "update" method. The $("#dp1").datepicker("update", "02-02-2012") or $("#dp1").datepicker("update", "02/02/2012") works for me. Surprisingly no document about this method at author website. Thanks.

How to use DataTables fnDestroy method

I am using the DataTables plugin for jQuery but keep getting the following error when I attempt to use the fnDestroy method:
Undefined
I have tried using all of the following variants:
1)
$('#data').dataTable().fnDestroy();
2)
var dt = $('#data').dataTable();
dt.fnDestroy();
3)
var data = document.getElementById('data');
data.fnDestroy();
The 'data' object exists - The HTML is as follows:
<div class="resultset">
<table class="display" id="data">
<tbody>
</tbody>
</table>
</div>
The DataTable is built with Javascript (not shown here), but the base object is hard-coded.
The API documentation shows that the second method should work:
$(document).ready(function() {
// This example is fairly pointless in reality, but shows how fnDestroy can be used
var oTable = $('#example').dataTable();
oTable.fnDestroy();
} );
EDIT
The DataTable displays fine and otherwise works well. The issue arises when I attempt to execute this function.
It seems to be the difference between...
_table = jQuery('table#fp-table-table').dataTable(); // .fnDestroy() works
and
_table = jQuery('table#fp-table-table').DataTable(); // .fnDestroy() doesn't work
DataTable seems to be for API calls back into the object and dataTable seems to be the intialisation method.
In my project I had changed the initialisation to use DataTable instead of dataTable to perform a filtering task. After this my AJAX reloads would throw the 'undefined' error, so I changed it back... i esta.
If you go to http://www.datatables.net/manual/installation and scroll towards the bottom you will see the following:
"Upgrade note:
If you are upgrading from DataTables 1.9 or earlier, you might notice that a capital D is used to initialise the DataTable here. $().DataTable() returns a DataTables API instance, while $().dataTable() will also initialise a DataTable, but returns a jQuery object.
Please refer to the API manual for further information.
Are you sure you are running your fnDestroy within document.ready?
Maybe you are getting the undefined error because the dom is not correctly loaded yet ?
It could also mean your table is incorrect, but I would have to be able to look at that to be sure.
Take a look at this fiddle, which uses your second option, and runs perfectly: http://jsfiddle.net/timsommer/m5sZU/2/
From the datables 1.10 manual:
It is important to note the difference between $( selector ).DataTable() and $( selector ).dataTable(). The former returns a DataTables API instance, while the latter returns a jQueryJS object. An api() method is added to the jQuery object so you can easily access the API, but the jQuery object can be useful for manipulating the table node, as you would with any other jQuery instance (such as using addClass(), etc.).
So you can use DataTable() but then you need to use _table.api().fnDestroy(); it seems.
You can try
table.destroy()
This works in my case

comparing sorted or removed rows in dojox.grid.EnhancedGrid to dojo.data.ItemFileWriteStore

I've scoured the dojo documentation, stack overflow, as well as thoroughly explored the EnhancedGrid object itself with firebug, and I'm not finding answers.
I have an enhanced grid that I populate with values for the user to sort on and basically create a selection set (using indirectSelection plugin). They then have a button to zoom to the selected items on a map.
The problem is, when sorting columns, it doesn't change the order of the items in the store itself, where I'm keeping an object inside each item that tells me how to zoom on the map, so I have no way to reconcile the grid.selection.selected array indices with the store._arrayOfAllItems indices.
edit: Note that I'm stuck using Dojo 1.6 as it's baked into the API I'm using.
Have a look at Dojo Object Store Tutorial.
You can set an idProperty to a Store, e.g.:
var employeeStore = new dojo.store.Memory({data:employees, idProperty: "name"});
Then you can operate the store with that id property using the get method like this:
// add a new employee
employeeStore.add({name:"George", department:"accounting"});
// remove Bill
employeeStore.remove("Bill");
// retrieve object with the name "Jim"
var jim = employeeStore.get("Jim");
Instead of using store._arrayOfAllItems. That way your grid.selection object will contain your id's values instead of array indexes (provided that your grid's store property is your store). This is the part that I'm guessing will work because I know for sure that the new dojo's dgrid does it that way, which I encourage you to use it BTW.
Hope it helps,

Ext.grid.ColumnModel is not a constructor

I am quite new to extjs..and I installed ext js4 in my server. I get the following error. Not sure what it means:
Ext.grid.ColumnModel is not a constructor
here 's my link:
http://srikanthrajan.com/test/index.html
Now I get Ext.grid.RowSelectionModel is not a constructor
Basically I am trying the following tutorial:
http://www.sencha.com/learn/ext-js-grids-with-php-and-sql
RowModel is default so in your grid configurations try this:
selModel: { mode: 'SIMPLE' },
or
selModel: new Ext.selection.RowModel({singleSelect:false})
although singleSelect is not a config option of RowModel, so try:
selModel: new Ext.selection.RowModel({model:SIMPLE})
From ExtJs docs:
mode : String
Mode of selection. Valid values are:
SINGLE - Only allows selecting one item at a time. Use allowDeselect to allow deselecting >that item. This is the default.
SIMPLE - Allows simple selection of multiple items one-by-one. Each click in grid will >either select or deselect an item.
MULTI - Allows complex selection of multiple items using Ctrl and Shift keys.
EDIT:
I looked at the code in the tutorial you mentioned and noticed that it is for ExtJs 2.x and 3.x versions. Grid changed a lot from version 3 to 4. If you want to follow that tutorial you will need to have ExtJs 4 documentation at hand.
I think the columns for PresidentsColumnModel should be Ext.grid.column.Column, not Ext.grid.ColumnModel