Ways to get items in extjs? - extjs3

How to get the item from the form.
Source:
Application.TypesForm = Ext.extend(Ext.form.FormPanel, {
initComponent : function() {
Ext.apply(this, {
...
items : [
{
xtype : 'VerticalsComboBox',
}
...
in VerticalsComboBox ajax request to fill a combobox, his name = vert_id.
I need to display the value vert_id.
Doing so:
form = Ext.getCmp('TypesForm');
alert(form.getForm().findField('status').getValue());
But not work, what i do wrong ?

Related

How to connect to SharePoint Online with IP address

I would like to know how to successfully connect to spo service url with a IP address.
Connect-SPOService https://13.xxx.xxx.9-admin.sharepoint.com
How about triggering the Excel export manually on button click using kendo.ooxml.Workbook combined with kendo.saveAs?
I have made up a Kendo Dojo example. Let me know if this is what you need. Additionally, if you need to retrieve the name of your screen, there are some examples of how to do this here
EDIT
Below is an example of the export generated by the Dojo example when the "Click to Export" button is pressed. Note that the title is custom.
Not sure why this would not work for you, but try the following example with your code and see what happens. Basically, you can hook up the custom function to handle the export button click as follows:
$("#exportButton").kendoButton({
click: function () {
var grid = $("#yourGrid").getKendoGrid();
// declare `rows` and supply your own column names
var rows = [{
cells: [
{ value: "ContactTitle" },
{ value: "CompanyName" },
{ value: "Country" }
]
}];
var trs = grid.dataSource;
// will get any filters applied to grid dataSource
var filteredDataSource = new kendo.data.DataSource({
data: trs.data(),
filter: trs.filter()
});
filteredDataSource.read();
var data = filteredDataSource.view();
for (var i = 0; i < data.length; i++) {
var dataItem = data[i];
rows.push({
cells: [ // dataItem."Whatever Your Attributes Are"
{ value: dataItem.ContactTitle },
{ value: dataItem.CompanyName },
{ value: dataItem.Country }
]
});
}
excelExport(rows);
}
});
This sets up the rows to be exported, and the excelExport function carries out the export:
function excelExport(rows) {
var workbook = new kendo.ooxml.Workbook({
sheets: [
{
columns: [
{ autoWidth: true },
{ autoWidth: true }
],
title: "Name of Tab",
rows: rows
}
]
});
var nameOfPage = "Test-1"; // insert here however you are getting name of screen
kendo.saveAs({ dataURI: workbook.toDataURL(), fileName: nameOfPage + " Export.xlsx" });
}
Let me know the outcome.

SAP UI5: Navigation from Master page and Detail page through two different OData URLs

I am trying to create a Master - Detail page using OData servicea in SAPUI5. Everything works fine in the Master page. Meaning I'm able to populate the list with valid data from SAP backend using an OData URL.
Now what I want to achieve is, to call a second OData URL to fetch the detail values and populate that in the page.
My Master.controller.js
handleListSelect : function (evt) {
var context = evt.getParameter("listItem").getBindingContext();
this.nav.to("Detail", context);
console.log('evt.getSource: ' + evt.getSource());
console.log('evt.getBindingContext: ' + evt.getSource().getBindingContext());
}
Console Output gives
"evt.getSource: Element sap.m.List#Master--list" sap-ui-core.js line 80 > eval:31
"evt.getBindingContext: undefined"
I'm unable to populate values in the detail page from the second URL. Can anyone guide or help me on this?
My Compenent.js
createContent : function() {
// create root view
var oView = sap.ui.view({
id : "app",
viewName : "sap.ui.demo.myFiori.view.App",
type : "JS",
viewData : {
component : this
}
});
// Using OData model to connect against a real service
var url = "/MyFioriUI5/proxy/sap/opu/odata/sap/XXXXXX;mo/";
var oModel = new sap.ui.model.odata.ODataModel(url, true, "", "");
oView.setModel(oModel);
// set i18n model
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl : "i18n/messageBundle.properties"
});
oView.setModel(i18nModel, "i18n");
// set device model
var deviceModel = new sap.ui.model.json.JSONModel({
isPhone : jQuery.device.is.phone,
isNoPhone : !jQuery.device.is.phone,
listMode : (jQuery.device.is.phone) ? "None" : "SingleSelectMaster",
listItemType : (jQuery.device.is.phone) ? "Active" : "Inactive"
});
deviceModel.setDefaultBindingMode("OneWay");
oView.setModel(deviceModel, "device");
// Using a local model for offline development
// var oModel = new sap.ui.model.json.JSONModel("model/mock.json");
// oView.setModel(oModel);
// done
return oView;
}
My Detail.controller.js
sap.ui.controller("sap.ui.demo.myFiori.view.Detail", {
handleNavButtonPress : function(evt) {
this.nav.back("Master");
},
onBeforeRendering : function() {
// this.byId("SupplierForm").bindElement("BusinessPartner");
},
handleApprove : function(evt) {
// show confirmation dialog
var bundle = this.getView().getModel("i18n").getResourceBundle();
sap.m.MessageBox.confirm(bundle.getText("ApproveDialogMsg"), function(oAction) {
if (sap.m.MessageBox.Action.OK === oAction) {
// notify user
var successMsg = bundle.getText("ApproveDialogSuccessMsg");
sap.m.MessageToast.show(successMsg);
// TODO call proper service method and update model (not part of this session)
}
},
bundle.getText("ApproveDialogTitle"));
}
});
I can't see the second URL you are refering to, but we handle it this way.
In Component.js:
var oView = sap.ui.view({
id: "app",
viewName: "fom.test.app.view.App",
type: "JS",
viewData: { component : this }
});
var dataModel = new sap.ui.model.odata.ODataModel("/fom/fiori/odata/FOM/mobile_app_srv", true);
oView.setModel(dataModel);
This connects the master view to the data for all the list items.
In the App.controller.js we make use of the onNavigation function, defined in Detail.controller.js. That means when routing to the detail view, the onNavigation function is called before the view is set up.
App.controller.js:
to : function (pageId, context) {
var app = this.getView().app;
// load page on demand
var master = ("Master" === pageId);
if (app.getPage(pageId, master) === null) {
var page = sap.ui.view({
id : pageId,
viewName : "fom.test.app.view.view." + pageId,
type : "XML"
});
page.getController().nav = this;
app.addPage(page, master);
jQuery.sap.log.info("app controller > loaded page: " + pageId);
}
// show the page
app.to(pageId);
// set data context on the page
if (context) {
var page = app.getPage(pageId);
page.setBindingContext(context);
try{
var oController = page.getController();
oController.onNavigation(context);
}
catch(e){ }
}
},
Detail.controller.js:
onNavigation: function(context) {
this.getView().bindElement({
path: context.sPath,
parameters: {
select: "Id," +
"Lifnam," +
"Rmwwr," +
"Waers," +
"Sendedatum," +
"Workflowtyp," +
"Sktodat," +
"Stufe," +
"MonFrgstA," +
"Bukrs," +
"Belnr," +
"Gjahr," +
"EdcObject," +
"BstatTxt",
expand: "Positions"
}
});
},
The bindElements() function, connects the detail view to the results of another web service call, which fetches all attributes mentioned in select and the line items which are fetched with the expand.
Now your first webservice call is loading only the data relevant for the master view list, and the second one all the information of the selected list item.
When you use the newer routing functionality of UI5, you will need to find another place for the hook. I haven't built that in yet.
oView.setModel(oModel);
You have this statement twice - the one would override the other - you need to provide an alternate reference to the second instance:
e.g.
oView.setModel(oModel, "local")

Reload Next JSON Data Grid ExtJS with Value from Ext Form

I'm trying to create grid data view from ExtJS with pagination.
Actually there's no issue when I create a simple data grid.
Then I want to create a "filter/search" function using Ext Form.
It's only work for page one. Here is my Ext Form Code below :
var winFilter = Ext.create('widget.window',{
title : 'Filter',
width : 400,
height : 200,
modal : true,
closeAction : 'hide',
items : frmFilter,
layout : 'fit',
bodyPadding: 5,
buttons:[
{
text : 'Filter',
handler: function(btn){
var win = btn.up('window');
var form = win.down('form');
tempProductID = form.getForm().findField('Product_ID').getSubmitValue();
tempDescription = form.getForm().findField('Description').getSubmitValue();
store.load({
params: {
start: 0,
limit: itemsPerPage,
productid: form.getForm().findField('Product_ID').getSubmitValue(),
description: form.getForm().findField('Description').getSubmitValue()
}
});
winFilter.hide();
}
},
{
text : 'Close',
handler: function(){
winFilter.hide();
}
}
]});
for the next page, my JSON return all data without using filtering value that I used before (Product ID and Description).
Please if any advice
Thanks bud.
params (when used as an argument of load method) are applied only once. If you want to apply these params to each request you have to modify proxy extraParams property:
Ext.apply(store.proxy.extraParams, {
productid: form.getForm().findField('Product_ID').getSubmitValue(),
description: form.getForm().findField('Description').getSubmitValue()
}, {});
store.load();
Else you can use store filter method (store.remoteFilter should be set to true):
store.filter([
{property: "productid", value: form.getForm().findField('Product_ID').getSubmitValue()},
{property: "description", value: form.getForm().findField('Description').getSubmitValue()
]);
But note that the filter part of request url has different form when filter approach is used. In this case filter part looks something like ?filter=[{'property':'productid','value':2}]&limit=10.... Whereas when params approach is used url looks something like ?productid=2&limit=10.... So when filter approach is used backend should parse filter property of request.

In extjs4 How to catch textarea's keypress event in controller

i am working in extjs. i have one textarea to enter word and one search button.I have view as-
Ext.define('Balaee.view.kp.Word.Word', {
extend : 'Ext.form.Panel',
id : 'WordId',
alias : 'widget.Word',
title : 'Dictionary',
height : 500,
items : [{
xtype : 'textfield',
fieldLabel : 'Enter the word',
name : 'wordtext',
//anchor:'100%',
allowBlank : false,
emptyText : 'Enter the word',
enableKeyEvents : true,
id : 'wordtext',
action : 'EnterAction'
},
{
xtype : 'button',
formBind : true,
fieldLabel : 'Search',
action : 'SearchAction',
text : 'Search'
}
]
});
And in controller i have function as-
SearchWord:function(button)
{
var j = Ext.getCmp('wordtext').getValue();
console.log("word is:"+j);
var answers = '{"data":[';
answers = answers + '{"word":"'+j+'"}'
answers =answers+']}';
console.log(answers);
var storeObject=this.getStore('kp.WordStore');
storeObject.load({
params:{
data: answers
},
callback: function(records,operation,success){
//console.log(records)
},
scope:this
});
var temp=Ext.getCmp('WordId');
temp.remove('WordInfoId');
var details=Ext.create('Balaee.view.kp.Word.WordInfo');
//details.region='center';
temp.add(details);
}
});
Now above function is working correctly when user is entering word in textarea and clicking on submit button. But i want to execute above "SearchWord" function of controller on enter button click also. i.e. If user will enter word in textarea and will press enter key then same function of controller needs to be executed.So how to catch textarea's enter key press event in controller?
Just listen for the specialKey event and call your function if the key is ENTER.
So in your controller's init function, do something like this:
this.control({
'#wordtext':{
specialkey: function(field, e){
if (e.getKey() == e.ENTER) {
//Do whatever you want here (such as call your SearchWord function)
}
}
}
});

Jeditable: how to set parameters based on dom element attributes

Often I find that I need to use jeditable on several areas each requiring different parameter settings.
For example I use jeditable with autosuggest input type, and then I need to pass different data sources to the different inputs.
I wanted to use just one instance of the editable plugin, and have tried to assign attr-values to the script, but obviously this does not work the way I'm approaching it..
I'm hoping someone can guide me a bit..
Essentially I would like to be able to set a jeditable parameter value based on the value of an ttribute of the dom element it is manipulating.
something like:
$('.editme').editable('savedata.php',{
loadurl : 'loaddata.php',
loaddata : { handle: $(this).attr('rel') }
});
then I could simply specify different load sources with:
<div id="fruits" class="editme" rel="myfruits">apples</div>
I didn't find the keyword this to work in this way..
How can I access the attributes of the dom element being manipulated dynamically for each jeditable binding?
here is another example of what I want to do:
authorsList = "".split(",");
// extend jeditable with autocomplete
$.editable.addInputType('autoc', {
element: function(settings, original) {
var input = $("<input />").autocomplete(settings.mdata, settings.autoc);
$(this).append(input);
return input; }
});
$('.editable.authors').editable('savedata.php',{
type : "autoc",
mdata : $(this).attr('rel'), // should hold the name 'authorsList'
onblur : 'ignore',
autoc : { multiple: true,
multipleSeparator: ',' },
loadurl : 'loaddata.php',
loadtype : 'POST',
loaddata : {handle: function(){ return eval($("#objhandle").val())}, lookuptype: 'mirror'},
submit : 'save',
cancel : 'cancel',
tooltip : "Click to edit",
style : "inherit",
cssclass : 'jedi',
id : "field",
name : "data",
submitdata : {
storetype: 'mirror',
handle: function(){return eval($("#objhandle").val())},
timestamp: function(){return eval($("#objtimestamp").val())}
}
});
Warning, totally untested code but something like following should work:
$('.editme').each(function() {
$(this).editable('savedata.php',{
loadurl : 'loaddata.php',
loaddata : { handle: $(this).attr('rel') }
});
});
This way the score of this should be correct when initializing Jeditable on the element.
this worked for me
$(this).data('rel)
and for the html
<div id="fruits" class="editme" data-rel="myfruits">apples</div>