createContent : function(oController) {
var oFileUploader = new sap.ui.commons.FileUploader({
id: "FileULoader",
//uploadUrl : "UploadFileServelet", // URL to submit the form to
name: "simpleUploader", // name of the input type=file element within the form
// uploadOnChange: true, // immediately upload the file after selection
buttonOnly: false,
buttonText: "Upload"
}).addStyleClass("downloadBtn");
oFileUploader.attachUploadComplete(oController.doFileLoadComplete);
//var uploadBtn=new sap.ui.commons.buttons{this.creatId("upLoadFile"),}
var oMatrix = new sap.ui.commons.layout.MatrixLayout({
layoutFixed : true,
width : '400px',
columns : 1 });
var text = new sap.ui.commons.TextView({text:"Confirm that the data will be wiped out once you upload new data file."});
oMatrix.createRow(oFileUploader);
oMatrix.createRow(text);
var oDialog = new sap.ui.commons.Dialog({
title:"FileUpload",
resizable:false,
modal:true,
showCloseButton:true,
contentBorderDesign:"Box",
content:[
oMatrix
],
buttons:[
new sap.ui.commons.Button({text:"Confirm", tooltip:"Confirm",press:function(e){oController.doFileUpload();oDialog.close();}}),
new sap.ui.commons.Button({text:"Cancel", tooltip:"Cancle",press:function(e){oDialog.close();}}),
]
});
return oDialog;
i used in two views . when i call the fileUploader the error turns out。
i have to use the id to identify the fileloder controller. to get the input file information .
update:
_uploadCourse:function(){
if (!this.dialogUploadFile) {
this.dialogUploadFile = sap.ui.jsfragment("courseUP",
"adminView.dialogUploadFile", this);
}
this.dialogUploadFile.open();
},
_uploadCourse : function() {
if (!this.dialogUploadFile) {
this.dialogUploadFile = sap.ui.jsfragment("certiUploadFile",
"adminView.dialogUploadFile", this);
}
this.dialogUploadFile.open();
},
this is how i use the fragment. but is still go wrong with thew same error;
#Allen Zhang
You mentioned you used the code in two views. You can't create a dialog twice with the same id of Fileupload control. Use different id for different views.
Updated:
Define id for your fragment usage:
<core:Fragment id="myFrag" fragmentName='my.frag' type='JS' />
Define fileupload id by calling createId:
var oFileUploader = new sap.ui.commons.FileUploader({
id: this.createId("FileULoader"),
//uploadUrl : "UploadFileServelet", // URL to submit the form to
name: "simpleUploader", // name of the input type=file element within the form
// uploadOnChange: true, // immediately upload the file after selection
buttonOnly: false,
buttonText: "Upload"
}).addStyleClass("downloadBtn");
Also see my answers about fragment usage and get control inside fragment.
Is an option that you do not use id for the file uploader control, and do it like this?
createContent : function(oController) {
this.oFileUploader = new sap.ui.commons.FileUploader({
To access it, you do
view.oFileUploader
where view is the javascript handle of one of your two views.
-D
Related
I know that there already is a 'View My Roles' under my account but I just need that page to reflect on a suitelet.
You will want to use the Suitelet Script Type, and methods available in the N/runtime Module (to get current user and role) and N/ui/serverWidget Module (to create the custom page). You can use methods in either the N/record Module or N/search Module (to gather user role data).
Here's a good start to how to outline your script. Once deployed as a Suitelet you will see a url provided. This will be the url to use to trigger the script. I do not know of a way to make the link attached to a Custom Center Tab, but minimally you can have users save the link to their NetSuite shortcuts, or browser shortcuts.
/**
* #NApiVersion 2.x
* #NScriptType Suitelet
*/
define(['N/ui/serverWidget', 'N/runtime', 'N/record'], function(serverWidget, runtime, record) {
function onRequest(context){
if(context.request.method === 'GET'){ //GET is the request method when clicking on the url, POST or ELSE logic can be entered if you want to add for example a "submit button"
//create list w/2 columnms to display results in
var list = serverWidget.createList({
title: 'Available User Roles'
});
list.style = serverWidget.ListStyle.REPORT;
list.addColumn({
id: 'column1',
type: serverWidget.FieldType.TEXT,
label: 'Active Role?',
align: serverWidget.LayoutJustification.LEFT
});
list.addColumn({
id: 'column2',
type: serverWidget.FieldType.TEXT,
label: 'Role Name',
align: serverWidget.LayoutJustification.LEFT
});
//get current user role
var curUser = runtime.getCurrentUser(); //returns User (likely Employee) internal id
var curUserRoleId = curUserRole.role; //returns current role internal id
//empty array to keep all available roles
var availRoles = new Array();
//get all available roles using search or record module
//push each result to the array
availRoles.push(XXX);
//use ids to identify which result found above is the current role
var curRolePosition = availRoles.indexOf(curUserRoleId);
//add data to the list using addRow or addRows
//can also use a for loop for each result found when getting all available roles using search or record module
list.addRow({
row : { columnid1 : 'value1', columnid2 : 'value2' }
});
list.addRows({
rows : [{columnid1 : 'value1', columnid2 : 'value2'},
{columnid1 : 'value2', columnid2 : 'value3'}]
});
//display list to the user
context.response.writePage(list);
} else { //code that is exectuted i.e. after user presses "Submit button" (if created above in the GET area)
}
}
return {
onRequest: onRequest
}
});
I'm trying to insert the checkbox value (as boolean) into a subschema of my collection. Not clear on 1) how to pass the checkbox value (can do it for normal input field) and 2) how to insert into subschema. I am using collection2 and handlebars.
1-This is what I have in the HTML form that needs to be submitted:
`<div class="checkbox">
<label><input type="checkbox" id="byow" checked="{{isChecked}}" value="">Bring Your Own Wine</label></div>`
2-This is what I have in my helper (in controller) to get the value of the form and the checkbox value, submit it and call the method that inserts it into the collection:
`BackendController.events({
//Add Venue - Add New Venue Submit Form Helper
'submit #add-venue-form' : function(event) {
event.preventDefault();
var venueName = event.target.venueName.value;
var byow = event.target.byow.checked;
var params = {
venueName: venueName,
byow: byow
}
//Insert Venue
Meteor.call('addVenue', params);
toastr.success('VenueAdded');
Router.go('/admin/manage-venues')
}
3-This is my method that is called to insert into my Venues collection (first part) and the structure of my collection and sub-collection:
`Meteor.methods({
'addVenue': function (params) {
Venues.insert(params);
}
// MAIN SCHEMA for the Venues colleciton.
Schema.Venues = new SimpleSchema({
venueName: {
type: String,
label: "Venue Name",
max: 200,
optional: false
},
//Attach schema for venue attributes (cuisine type, amenities, etc)
venueAttributes: {
type: Schema.VenueAttributes,
optional: true
}
});
//schema for venue attributes. Attached to main schema
Schema.VenueAttributes = new SimpleSchema({
byow: {
type: Boolean,
optional: true
}
});
Would really appreciate any help - I've managed to get the venueName to be passed successfully (so all my permissions/pub/sub is correct) but stuck at checkbox and subcollection.
Thanks!
Dan.
Finally figured it out with the help of #lokenx on Meteor Chef Slack channel.
The checkbox code (first part) returned the correct value (true) when written as above.
My error was that I was not specifying byow as a subproperty (was treating it as root property of the simpleschema). The correct params I should have been passing are:
var params = {
venuaName: venueName,
venueAttributes: {
byow: byow
}
}
my coding part
$("#demo-input").tokenInput("data/autosuggest-search-city.php",
{
searchDelay: 2000,
minChars: 3,
tokenLimit: 10
});
I want to send the selected values as extra parameter to "data/autosuggest-search-city.php".
For example,
Initially I search and select one value from list
then again searching, this time I want to send the 1st selected value to server.
How to do this?
TokenInput plugin doesn't support that natively.
You can however make a simple workaround to update "AJAX url" whenever a token is added or removed from selection.
Use onAdd and onDelete callbacks to trigger "AJAX url" changes;
Get selected tokens using selector.tokenInput("get") method;
Set the new "AJAX url" by updating .data("settings").url of the element;
// cache the original url:
var token_url = "data/autosuggest-search-city.php";
$("#demo-input").tokenInput(token_url, {
searchDelay : 2000,
minChars : 3,
tokenLimit : 10,
onAdd : function(){
urlChange.call(this);
},
onDelete : function(){
urlChange.call(this);
}
});
function urlChange(){
var tokens = '', token_list = $(this).tokenInput("get");
// proceed if any token/s are selected:
if(token_list.length){
// loop through the selected tokens (if more than one is selected)
$.each(token_list, function(i, token){
// use token "id" (or "name" if you wish) and separate them with comma:
tokens += token.id + ',';
});
// update url:
$(this).data("settings").url = token_url + '?selected_tokens='+tokens.replace(/,+$/,'');
}else{
// leave original url if no tokens are selected:
$(this).data("settings").url = token_url;
}
};
I have a model attached to my view:
Controller code:
var model =
{
title:"Scan RFID container",
question:"Please scan the RFID tag on the container",
answer:"",
type:"input",
options:"",
transaction : ""
};
var oQuestion = new sap.ui.model.json.JSONModel();
oQuestion.setData(model);
this.getView().setModel(oQuestion, "containerChecks");
In my view I can set the texts etc by using the curly brackets. This ofcourse only works for sapui5 elements that parse this content.
View code
this.page = new sap.m.Page({
title: "{containerChecks>/title}",
content: [
new sap.m.Text({
text: "{containerChecks>/question}"
})
],
});
However I want to do a check based on my model attribute 'options'.
I tried:
var options = this.getModel("containerChecks").getProperty("options");
but getModel returns null
As your setting the model in View by using this.getView().setModel() how can you access the model through this.getModel() try this
var options = this.getView().getModel("containerChecks").getProperty("options");
If your using above statement in a Controller.
I am sure that it may give you the options value.
This is my program skeleton http://jsfiddle.net/zhwzY/
$(document).ready(function(){
$("#btnSend").click(function(){
var option = {
'delay' : false,
'helpSpanDisplay' : 'help-block',
'disableSubmitBtn' : false
};
if($('#agree').is(':checked')){
form_input = 'input:not("#reason")';
}else{
form_input = 'input';
}
var metric = [
[ form_input, 'presence', 'Please fill this textbox!']
];
$("#frm").nod(metric, option);
});
});
From the snippet, I try to make variable "form_input" to switch to a new value depend on the checkbox. With this method, I can prevent NOD (validation plugins) from validating unecessary input. But the variable "form_input" is not changing to the new value upon updating.
Please help.
P/s : No external reference to the NOD library in jsFiddle.