How to show the data obtained from server in the table view cells when data is entered into searchbar and search button is clicked - tableview

I am new to ios development and working on services first time..When the user types something in the searchbar and clicks search button of keyboard it obtains response from server.The response from server is as follows:
(
{
Id = 2;
Name = Alex;
},
{
Id = 5;
Name = AMark;
}
)
I want to show this name obtained from server on click of search button of keyboard on the label of table view cells.How can I do this.Kindly suggest.

I fixed it..it was because of wrong constraints.

Related

UI Service error: please select active sheet first

I'm trying to replicate the code from this page. When I deploy as web app, it brings up the user interface with the input boxes and submit button. However, when I click submit, it brings up this error message: "please select an active sheet first". When I bring up the UI in the spreadsheet itself, I get the same error. Instead of using openById I changed it to getActive.getSheetByName and it worked from the spreadsheet. However, going back to the web app, the new error message is now "Cannot call getSheetByName of null."
Can anyone suggest why I'm getting the "please select an active sheet first" error and what I need to do differently?
Here's the code I've copied, the only change I made was to put my SS key in the two appropriate places.
function doGet(e) {
var doc = SpreadsheetApp.openById("yyyy"); //I've got my SS key here
var app = UiApp.createApplication().setTitle('New app');
// Create a grid with 3 text boxes and corresponding labels
var grid = app.createGrid(3, 2);
grid.setWidget(0, 0, app.createLabel('Name:'));
// Text entered in the text box is passed in to userName
// The setName method will make those widgets available by
// the given name to the server handlers later
grid.setWidget(0, 1, app.createTextBox().setName('userName'));
grid.setWidget(1, 0, app.createLabel('Age:'));
grid.setWidget(1, 1, app.createTextBox().setName('age'));
// Text entered in the text box is passed in to age
grid.setWidget(2, 0, app.createLabel('City'));
grid.setWidget(2, 1, app.createTextBox().setName('city'));
// Text entered in the text box is passed in to city.
// Create a vertical panel..
var panel = app.createVerticalPanel();
// ...and add the grid to the panel
panel.add(grid);
// Create a button and click handler; pass in the grid object as a callback element and the handler as a click handler
// Identify the function b as the server click handler
var button = app.createButton('submit');
var handler = app.createServerHandler('b');
handler.addCallbackElement(grid);
button.addClickHandler(handler);
// Add the button to the panel and the panel to the application, then display the application app
panel.add(button);
app.add(panel);
return app;
}
// Function that records the values in a Spreadsheet
function b(e) {
var doc = SpreadsheetApp.openById("yyyy"); //I've got my SS key here
var lastRow = doc.getLastRow(); // Determine the last row in the Spreadsheet that contains any values
var cell = doc.getRange('a1').offset(lastRow, 0); // determine the next free cell in column A
// You can access e.parameter.userName because you used setName('userName') above and
// also added the grid containing those widgets as a callback element to the server
// handler.
cell.setValue(e.parameter.userName); // Set the value of the cell to userName
cell.offset(0, 1).setValue(e.parameter.age); // Set the value of the adjacent cell to age
cell.offset(0, 2).setValue(e.parameter.city); // set the value of the next cell to city
// Clean up - get the UiInstance object, close it, and return
var app = UiApp.getActiveApplication();
app.close();
// The following line is REQUIRED for the widget to actually close.
return app;
}
Thanks!
You are opening the spreadsheet and should open the sheet in the spreadsheet
sheet = doc.getSheetByName("sheet name")
The documentation

Tridion Date Picker - access to events

I have a Tridion Date control added to a GUI Extension .aspx page I have created.
I've added this to the ASPX page with
<c:Date id="AdjustDate" runat="server"
IsSeparateFields="false" AddClearButton="false" TabIndex="3"></c:Date>
and in my .JS I've added the following to
Give me a handle onto the Tridion Date Control (to select the date values etc.)
c.AdjustDate =
$controls.getControl($("#AdjustDate"),
"Tridion.Controls.Date")
Capture changes in the date (after the user selects OK in the modaldialog)
$evt.addEventHandler(c.AdjustDate, "change",
this.getDelegate(this._onHighlightDateChange));
I capture the event and perform some updates based on the date selected.
However, my GUI extension dialog is smaller in height than when the modal dialog is shown. I'd like to resize my ASPX dialog when the user clicks Select Date and the modal dialog is presented.
I've now captured the event of the user clicking the Select Date button
c.BtnDateSelect = $controls.getControl($("#AdjustDate_selectbutton"),
"Tridion.Controls.Button");
$evt.addEventHandler(c.BtnDateSelect, "click",
this.getDelegate(this._onDateButtonClicked));
However - I can't seem to access the height of the resulting dialog as I can't add any events to tie in
the opening of the dialog itself
the user clicking OK or Cancel (to adjust the height again) or
the modal dialog being closed
Am I missing events to tie into?
I've tried to create a handle to the OK button using
BtnDateOKSelect =
$controls.getControl($("html#DatePickerPopup.popup body center div#buttonContainer div#ButtonOk.tridion"),
"Tridion.Controls.Button");
but the reference (and variations of it) return undefined - possibly as this is in an iframe so the script can't access it?
Any pointers on working out what the events are I can tie into?
How to tie into those events (and when)?
Thanks
You cannot resize a dialog (modal) after it has been open. I wrote an extension where I had a similar problem, when my date picker was over my modal dialog, It look weird, so I made my dialog date picker bigger.
However I wasn't using a date picker control, but a regular html button. Here the code:
So I retrieve button and add the handler to show the date picker:
c.BtnStartDate = $controls.getControl($("#startDate"), "Tridion.Controls.Button");
$evt.addEventHandler(c.BtnStartDate, "click", this.getDelegate(this._onStartDateButtonClicked));
This is the code in the event:
SetDateRange$_onStartDateButtonClicked(event) {
this._setDate(event, "#startDate");
};
And the setDate function:
SetDateRange.prototype._setDate = function SetDateRange$_setDate(event, controlSelector) {
var p = this.properties;
var currentDate = new Date();
var c = p.controls;
p.datePickerPopup = $popup.create(
$cme.Popups.DATE_PICKER.URL, {
width: 550,
height: 350
},
{
date: currentDate,
popupType: Tridion.Controls.Popup.Type.MODAL_IFRAME
}
);
function SetDateRange$DatePicker$onPopupCanceled(event) {
if (p.datePickerPopup) {
p.datePickerPopup.dispose();
p.datePickerPopup = null;
}
}
function SetDateRange$DatePicker$onPopupSubmitted(event) {
var value = event.data.date;
if (value) {
var value = new Date(value);
value = $localization.getFormattedDateTime(value, Tridion.Runtime.LocaleInfo.fullDateTimeFormat);
jQuery(controlSelector).trigger('setdate', [value]);
}
p.datePickerPopup.dispose();
p.datePickerPopup = null;
}
$evt.addEventHandler(p.datePickerPopup, "unload", SetDateRange$DatePicker$onPopupCanceled);
$evt.addEventHandler(p.datePickerPopup, "submit", SetDateRange$DatePicker$onPopupSubmitted);
$evt.addEventHandler(p.datePickerPopup, "close", SetDateRange$DatePicker$onPopupCanceled);
p.datePickerPopup.open();
};
Again, it might not be the solution to your scenario, but this example shows how to open the date picker dialog and use the values it returns, without using the "Tridion Date Picker Control".
Hope this helps.

YUI DataTable Button events lost after filtering

I'm using a YUI2 DataTable.
Some of the rows of the tables have an icon button that when clicked on will popup additional details for the row.
I'm doing the following to define the panel which gets displayed with the additional information:
MyContainer.panel2 = new YAHOO.widget.Panel("popupPanel2",
{ width:"650px", visible:false, constraintoviewport:true, overflow:"auto" } );
MyContainer.panel2.render();
YAHOO.util.Event.addListener("showButton2", "click",
MyContainer.panel2.show, MyContainer.panel2, true);
So, everything works well with that. Then I added a button that when clicked on filters out some of the rows.
MyContainer.oPushButton1.onclick = function onButtonClickp(p_oEvent)
{
var filter_val = "xxx";
myDataTable.getDataSource().sendRequest(filter_val,
{success: myDataTable.onDataReturnInitializeTable},myDataTable);
}
This filters and redraws the table. But after doing that, the buttons on the remaining rows that should popup a panel no longer work.
Nothing happens when I click on the buttons.
I'm sure I've done something wrong, but I don't know what. The buttons and panels with the correct id's still seem to be available on the page.
Do I somehow have to re-enable the listener for the click event after the datatable redraw? I'm not sure where to look for trying to debug the failed listener.
I got this working by making a call to addListener again after resetting the data for the Datasource.
MyContainer.oPushButton1.onclick = function onButtonClickp(p_oEvent)
{
var filter_val = "xxx";
myDataTable.getDataSource().sendRequest(filter_val,
{success: myDataTable.onDataReturnInitializeTable},myDataTable);
YAHOO.util.Event.addListener("showButton2", "click",
MyContainer.panel2.show, MyContainer.panel2, true);
}

How to validate two textbox at same time?

Hi in my web application there are 3 textbox. Id, Name, and Date. User can search either by Id or by Name and Date. That is if user enter an Id and hit enter details are displayed. or if user enter Name and date and hit enter details are displayed. When user click submit it should validate in such a way if Name text box is empty and Date textbox contains some data it should show an "" after empty textbox with validation summary having error. In the same way if Date text box is empty and Name contains some data it should show an "" after empty textbox with validation summary having error. I am using server side validation methods for custom validation. Can any one help me with this?
Take a look at this link
http://authors.aspalliance.com/joteke/validationarticle1/article.aspx
or
You can try this one too
add two textboxes to your form (textBox1 and textBox2)
add a custom validator controls (CustomValidator1)
double click on the CustomValidator1 and create the
following:
private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
if(args.Value!=""&&TextBox2.Text=="")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}

Mozilla Extension - tracking data per opened tab

In a firefox extension I'm temporarily saving data in javascript to show in a sidebar. When a tab is selected, I want to change the text in the sidebar to the right data. What is the best object to use as the "Identifier" for each tab? I'm trying to use the tab object. However, I'm stuck then on how to associate the data to the tab. Currently, I get a load event on the document in a tab. Then I process the data in the document. AFter showing the new data in the tab, I want to save it into a map with the tab as the key so that I can retrieve it on a SelectTab event. However, I'm not sure how to find the tab from the documentin the load event.
So please either tell me how to get the tab object from the document object, or a better thing to use as the key.
The following is one way I've found, but I'm sure there is something more elegant.
getTabForDocument : function (document) {
var wm = Components.classes["#mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
for (var found = false, index = 0, tabbrowser = wm.getEnumerator('navigator:browser').getNext().gBrowser;
index < tabbrowser.tabContainer.childNodes.length && !found;
index++) {
// Get the next tab
var currentTab = tabbrowser.tabContainer.childNodes[index];
if (currentTab.linkedBrowser.contentWindow.document == document)
{
return currentTab;
}
}
return null;
},
Thanks...
Take a look at: https://developer.mozilla.org/en/Code_snippets/Tabbed_browser, especially the gBrowser.selectedBrowser section and https://developer.mozilla.org/En/Listening_to_events_on_all_tabs
To associate data with a tab you can use the setUserData method on the browser.
To get the browser for a document use the getBrowserForDocument method on the gBrowser global object.

Resources