Programmatic way to change page size - google-app-maker

When I'm manipulating large data sets I don't want to have to page through them on the execution side, so I have the pageSize set to 0, but when i'm displaying it I want them to pages.
On the "datasources" page of the appmaker resources it says
"For example, you can let the user control how many records are shown
by binding a slider widget's value property to the datasource pageSize
property."
How do I actually manipulate the pageSize property? this doesn't seem to work:
app.datasources.filesToCopy.properties.pageSize = 0;
app.datasources.filesToCopy.properties.pageSize = 20;
Anyone with any experience on this?
and this gives undefined:
Page length: undefined
console.log("Page length: "+app.datasources.filesToCopy.properties.pageSize);

The answer is this:
app.datasources.filesToCopy.query.pageSize = 0;

Related

Is it possible to load AppMaker DropDowns with an Option Text and and Value?

I've been able to set the options on an AppMaker DropDown by doing this sort of thing:
google.script.run
.withSuccessHandler(function(oA){app.pages.Notes.descendants.Dropdown1.options=oA;})
.getSelectOptions();//oA is just an array
But I'd like to know how to do load different values in the options and value like we can do it in javascript with something like this:
function updateSelect(vA){
var select = document.getElementById("sel1");
select.options.length = 0;
for(var i=0;i<vA.length;i++)
{
select.options[i] = new Option(vA[i].option,vA[i].value);
}
}
And I tried this by trying to get a hold of the dom element as follows:
var elem=app.pages.myPage.descendants.myDropDown.getElement();
elem.options.length=0;//always gives me an error because options doesn't seem to exist in that object.
So for now I've been using the standard HTML dom elements in an AppMaker Html widget and that works okay as long as your select is on the first page. If it's not on the first page I have found that the onChange event can't load Widgets on pages that are not visible. It is interesting to note however that you can change the contents of HTML widgets even if they are on other non visible pages.
Anyway the simple question is how can one load one thing into value and another thing into option text in an AppMaker DropDown Widget?
<option value="value">text</option>
If you have a predefined array for your options and values you could do the following for your onAttach Event of your dropdown:
var options = ['one thing','two thing','three thing'];
var names = ['another one thing','another two thing','another three thing'];
widget.options = options;
widget.names = names;
In this case the values that would get recorded would be the options array, but the items that would be displayed would be from the names array. Hope this gets you on the right path.

How to Print a Join Form?

Having difficulty figuring out how to print the contents of a Join form in BMC Remedy 9.0. Remedy's docs only explain printing Reports, not Join forms. I would like to either be able to print using Ctrl-P or by an internal Remedy process/action link. My Join form contains mostly character fields. Print preview truncates at the first ~20 px of height, despite a page width: 915 px and height: 1000 px. Does anyone know how I can print forms in the browser?
Figured out how to this - if you place all the content inside a Remedy panel object via the WYSIWYG, then you can add a script in the Web Footer to set the document.body.innerHTML equal to the panel's innerHTML. This little trick organizes the elements in a way that makes the page printable using window.print() or Ctrl-P. Be warned, though, that this innerHTML assignment often corrupts or loses properties like child textarea or input values. So you must scrape for these values and append them back to the page before printing.
<div>
<script>
function myPrint()
{
var idTexts = [];
var textareas = document.querySelectorAll('textarea[id][readonly]');
for(var i = 0; i < textareas.length; i++)
{
idTexts.push(textareas[i].id);
idTexts.push(textareas[i].value);
}
var inputs = document.querySelectorAll('input[id][readonly]');
for(var i = 0; i < inputs.length; i++)
{
idTexts.push(inputs[i].id);
idTexts.push(inputs[i].value);
}
//Assume there is only one panel object, so only one .pnl class on the page
var printContents = document.querySelector('.pnl').innerHTML;
document.body.innerHTML = printContents;
for(var i = 0; i < idTexts.length; i++)
{
if(document.getElementById(idTexts[i]))
{
document.getElementById(idTexts[i]).value = idTexts[i+1];
}
}
window.print();
}
/*On page load, I noticed the click event fired for a visible button
without the user actually needing to click.
Will not work unless the button's visibility is set to true (Remedy is a weird creature).
Used the setTimeout to allow time for the initial page load, as the onload event fired too early.
If you don't want this button to appear on the page when it is printed
overlay a transparent image on the button's display properties.*/
document.querySelector('a[ardbn="btnPrintMe"]').onclick = setTimeout(function(){ myPrint(); }, 500);
</script>
</div>
If you still have problems printing, make sure this btnPrintMe button has at least the correct 6 privileges: 1101/-1101, 1102/-1102, 1103/-1103 and the user you are testing this with has the appropriate privileges as well.

How to get values from Repeater control

I am using repeater control to display online question paper to user. I am showing 50 questions to user. And i am giving 4 check boxes for every question to select answer. Now my doubt is how to get all 50 options that checked by user, and to compare those answers with correct answer tag in my XML. I am using XML file, not database.
Can anyone please help me how to achieve this functionality?
You have to iterate Repeater control, like...
if (Repeater1.Items.Count > 0)
{
for (int count = 0; count < Repeater1.Items.Count; count++)
{
CheckBox chk = (CheckBox)Repeater1.Items[count].FindControl("CheckBox1");
if (chk.Checked)
{
}
}
}
To get access to Repeater items you should use:
repeaterId.Items
To get access to all checked controls of a repeater (which are definitely RadioButton controls, as you should have one option per question), you can use:
foreach (ListViewDataItem item in repeaterId.Items)
{
// Finding RadioButton controls by Id
RadioButton firstOption = ((RadioButton)item.FindControl("firstOption"));
RadioButton secondOption = ((RadioButton)item.FindControl("secondOption"));
RadioButton thirdOption = ((RadioButton)item.FindControl("thirdOption"));
RadioButton fourthOption = ((RadioButton)item.FindControl("fourthOption"));
// Here you have four RadioButtones and you should only see which one of them is clicked. Then compare its value to correct value in your XML file.
}

How do I maintain position of a DragPanelExtender across postbacks?

I already found this article:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1
But I've got a different situation. I am embedding some hiddenFields inside of the master page and trying to store the position of the dragPanel in those.
I am using javascript to store the position of the dragPanel and then when the user clicks on a link, the new page is loaded, but the dragPanel is reset into the starting position.
Is there any easy way to do this?
Pseudocode:
**this is in MasterPage.master**
function pageLoad()
{
// call the savePanelPosition when the panel is moved
$find('DragP1').add_move(savePanelPosition);
var elem = $get("<%=HiddenField1.ClientID%>");
if(elem.value != "0")
{
var temp = new Array();
temp = elem.value.split(';');
// set the position of the panel manually with the retrieve value
$find('<%=Panel1_DragPanelExtender.BehaviorID%>').set_location(new
Sys.UI.Point(parseInt(temp[0]),parseInt(temp[1])));
}
}
function savePanelPosition()
{
var elem = $find('DragP1').get_element();
var loc = $common.getLocation(elem);
var elem1 = $get("<%=HiddenField1.ClientID%>");
// store the value in the hidden field
elem1.value = loc.x + ';' + loc.y;
}
<asp:Button ID="Button1" runat="server" Text="Button"/>
<asp:HiddenField ID="HiddenField1" runat="server" Value="0"
However, HiddenField is not visible in the redirected page, foo.aspx
Rather than storing the position information in a hidden field, store it in a cookie. The information is small, so it will have minimal effect on the page load performance.
ok so I got the drag stuff to work, saves in a database and all, brings up cool on my one monitor 1600X1050 all good, fine and dandy! BUT WAIT! I bring up the same page on my other monitor 1366x768 and the panels are all off.
The save function saves in pixels, so when you move over to another "resolution" the panels are off. ya know?
P.S. I could pop up a message stating the user to change their monitor settings, lol...

Flex ComboBox, default value and dataproviders

I have a Flex ComboBox that gets populated by a dataprovider all is well...
I would now like to add a default " -- select a item --" option at the 0 index, how can I do this and still use a dataprovider? I have not seen any examples of such, but I can't imagine this being hard...
If you don't need the default item to be selectable you can use the prompt property of ComboBox and set the selectedIndex to -1. That will show the string you set propmt to as the selected value until the user chooses another. It will not appear in the list of options, however.
I came across this problem today and wanted to share my solution.
I have a ComboBox that has an ArrayCollection containing Objects as it's dataprovider. When the application runs, it uses a RemoteObject to go out and get the ArrayCollection/Objects. In my event handler for that call I just have it append another object to the beginning of the ArrayCollection and select it:
var defaultOption:Object = {MyLabelField: "Select One"};
myDataProvider.addItemAt(defaultOption, 0);
myComboBox.selectedIndex = 0;
This is what my ComboBox looks like for reference:
<mx:ComboBox id="myComboBox" dataProvider="{myDataProvider}" labelField="MyLabelField" />
The way I've dealt with this in the past is to create a new collection to serve as the data provider for the combobox, and then I listen for changes to the original source (using an mx.BindingUtils.ChangeWatcher). When I get such a notification, I recreate my custom data provider.
I wish I knew a better way to approach this; I'll monitor this question just in case.
This can be used following code for selected default value of combobox
var index:String = "foo";
for(var objIndex:int = 0; objIndex < comboBox.dataProvider.length; objIndex++) {
if(comboBox.dataProvider[objIndex].label == index)
{
comboBox.selectedIndex = objIndex;
break;
}
}
<mx:ComboBox id="comboBox" dataProvider="{_pageIndexArray}" />

Resources