SAP Fiori UI5 Capturing snapshot from video - sapui5

I'm doing a small crud operation. I want to capture more than one image from the video. I am using a fixedDialog while doing this. But after taking a picture, I can't see the video while opening the fixedDialog again. I share my codes below.
First time opening video,
After capturing,
<Button text="Resim Ekle" width="100px" id="idCapture" press="takePhoto"/>
<Vbox id="wow">
<Vbox id="canvasContainer">
</Vbox>
</Vbox>
takePhoto: function(oEvent) {
// Create a popup object as a global variable
var that = this;
that.fixedDialog = new Dialog({
title: "Fotoğraf çekmek için tıklayınız",
beginButton: new sap.m.Button({
text: "Resim Çek",
press: function() {
that.imageVal = document.getElementById("player");
that.fixedDialog.close();
}
}),
content: [
new sap.ui.core.HTML({
content: "<video id='player' autoplay/>"
}),
new sap.m.Input({
placeholder: 'Lütfen resim adını giriniz',
required: false
})
],
endButton: new sap.m.Button({
text: "İptal",
press: function() {
that.fixedDialog.close();
}
})
});
that.getView().addDependent(this.fixedDialog);
this.fixedDialog.open();
that.fixedDialog.attachBeforeClose(this.setImage, this);
var handleSuccess = function(stream) {
player.srcObject = stream;
};
navigator.mediaDevices.getUserMedia({
video: true
}).then(handleSuccess);
},
setImage: function() {
var oVBox = this.getView().byId("wow");
var canvasContainer = this.getView().byId("canvasContainer");
var items = oVBox.getItems();
var snapId = 'canvas-' + items.length;
var textId = snapId + '-text';
var imageVal = this.imageVal;
var snapImg = null;
var snapCanvas = new sap.ui.core.HTML({
content: "<canvas display:none id='" + snapId + "' width='400' height='200' ></canvas>"
});
oVBox.addItem(snapCanvas);
snapCanvas.addEventDelegate({
onAfterRendering: function() {
var canvasElem = document.getElementById(snapId);
var snapCanvasContext = canvasElem.getContext('2d');
snapCanvasContext.drawImage(imageVal, 0, 0, canvasElem.width, canvasElem.height);
}
});
}

I suggest you to check if your this.fixedDialog exists before performing a new Dialog(): I suspect you are adding more than one <video id='player' autoplay/> when you are opening the Dialog again...

I suggest you to add only
that.fixedDialog.destroy();
in press event
my code is below
takePhoto: function (oEvent) {
debugger;
// Create a popup object as a global variable
var that = this;
that.fixedDialog = new sap.m.Dialog({
title: "Open Camera For Video",
beginButton: new sap.m.Button({
text: "Capture",
press: function () {
that.imageVal = document.getElementById("player");
that.fixedDialog.close(this);
that.fixedDialog.destroy();
}
}),
content: [
new sap.ui.core.HTML({
content: "<video id='player' autoplay/>",
}),
new sap.m.Input({
placeholder: 'Name',
required: false
})
],
endButton: new sap.m.Button({
text: "Close",
press: function () {
that.fixedDialog.destroy();
that.fixedDialog.close();
}
})
});
that.getView().addDependent(this.fixedDialog);
this.fixedDialog.open();
that.fixedDialog.attachBeforeClose(this.setImage, this);
var handleSuccess = function (stream) {
player.srcObject = stream;
};
navigator.mediaDevices.getUserMedia({
video: true
}).then(handleSuccess);
},
setImage: function () {
var oVBox = this.getView().byId("wow");
var canvasContainer = this.getView().byId("canvasContainer");
var items = oVBox.getItems();
var snapId = 'canvas-' + items.length;
var textId = snapId + '-text';
var imageVal = this.imageVal;
var snapImg = null;
var snapCanvas = new sap.ui.core.HTML({
content: "<canvas display:none id='" + snapId + "' width='400' height='200' ></canvas>"
});
oVBox.addItem(snapCanvas);
snapCanvas.addEventDelegate({
onAfterRendering: function () {
var canvasElem = document.getElementById(snapId);
var snapCanvasContext = canvasElem.getContext('2d');
snapCanvasContext.drawImage(imageVal, 0, 0, canvasElem.width, canvasElem.height);
}
});
}

Related

The hunt for the missing dialog value ^^

Helloooo experts,
I have a dialog which I use both for creating and updating entries. Everything works fine, except a tiny (but still annoying) bit.
When I call the dialog for an existing entry, everything is smooth. Fields appear normally and update works alright.
When I call the dialog to create a new entry, I get a set of blank fields, I fill them all, press save and works OK. Where is the problem? One of these fields should have already a value since I have already assign a value with the oModel.createEntry method. I debug the app the properties for the entry look alright, everything seems alright (if not blind) but the value doesn't come with the field - rings any bells?
Code (quite short) attached below, field in doubt: iAgrId.
Thanks!
Greg
Debugger snapshot
onActionAdd: function() {
var oModel = this.getView().getModel();
//oModel.createEntry("/Agreement_ActionsSet");
var oActionEditDialog = new Dialog({title: "Create Action"});
this.createActionFormData(oActionEditDialog, oModel);
//get Agreement ID
var sAgreement = this.getView().getBindingContext().toString().slice(16,26);
var oNewObject = "{\"AgrId\": \"" + sAgreement + "\"}";
oNewObject = JSON.parse(oNewObject);
this.getView().addDependent(oActionEditDialog);
var oEntry = oModel.createEntry("/Agreement_ActionsSet", oNewObject);
oActionEditDialog.setBindingContext(oEntry);
//oActionEditDialog.bindElement(oEntry);
oActionEditDialog.open();
},
onActionEdit: function(oSourceEvent) {
var oModel = this.getView().getModel();
var oActionEditDialog = new Dialog({title: "Edit Action Details"});
this.createActionFormData(oActionEditDialog, oModel);
//to get access to the global model
var sPath = oSourceEvent.getSource().getParent().getBindingContext().toString();
this.getView().addDependent(oActionEditDialog);
oActionEditDialog.bindElement(sPath);
oActionEditDialog.open();
},
// populate form fields
createActionFormData: function(oActionEditDialog, oModel) {
var oActionTypeItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrActtypeid}", text:"{f4>AgrActtypeid}", additionalText:"{f4>AgrActtypetxt}"});
var oActionStatusItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrStatid}", text:"{f4>AgrStatid}", additionalText:"{f4>AgrStattxt}"});
var oActionAgentItemTemplate = new sap.ui.core.ListItem({ key:"{f4>AgrAgentid}", text:"{f4>AgrAgentid}", additionalText:"{f4>AgrAgenttxt}"});
var sAgrId = new sap.m.Label({text: "{i18n>actionAgrId}"});
var iAgrId = new sap.m.Input({value: "{AgrId}"});
var sAgrActionid = new sap.m.Label({text: "{i18n>actionLineItemTableIDColumn}"});
var iAgrActionid = new sap.m.Input({value: "{AgrActionid}", enabled: false});
var sCreatedBy = new sap.m.Label({text: "{i18n>actionCreatedBy}"});
var iCreatedBy = new sap.m.Input({value: "{CreatedBy}"});
var sCreatedOn = new sap.m.Label({text: "{i18n>actionCreatedOn}"});
var iCreatedOn = new sap.m.DatePicker({value: "{ path: 'CreatedOn', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
var sActionComment = new sap.m.Label({text: "{i18n>actionComment}"});
var iActionComment = new sap.m.Input({value: "{ActionComment}"});
var sAgrActionDate = new sap.m.Label({text: "{i18n>actionActionDate}"});
var iAgrActionDate = new sap.m.DatePicker({value: "{ path: 'AgrActionDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
var sAgrChaseDate = new sap.m.Label({text: "{i18n>actionChaseDate}"});
var iAgrChaseDate = new sap.m.DatePicker({value: "{ path: 'AgrChaseDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true} }"});
var sAgrActtypeid = new sap.m.Label({text: "{i18n>actionActionType}"});
var iAgrActtypeid = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrActtypeid}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Action_TypesSet",
template: oActionTypeItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrActtypeid");
var sAgrStatidFrom = new sap.m.Label({text: "{i18n>actionStatusFrom}"});
var iAgrStatidFrom = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrStatidFrom}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_StatusesSet",
template: oActionStatusItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrStatidFrom");
var sAgrStatidTo = new sap.m.Label({text: "{i18n>actionStatusTo}"});
var iAgrStatidTo = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrStatidTo}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_StatusesSet",
template: oActionStatusItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrStatidTo");
var sAgrAgentidFrom = new sap.m.Label({text: "{i18n>actionAgentFrom}"});
var iAgrAgentidFrom = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrAgentidFrom}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_AgentsSet",
template: oActionAgentItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrAgentidFrom");
var sAgrAgentidTo = new sap.m.Label({text: "{i18n>actionAgentTo}"});
var iAgrAgentidTo = new sap.m.ComboBox({
//id: "cbRoleType",
selectedKey: "{AgrAgentidTo}",
//selectedItemId: "{AgrRoletptxt}",
showSecondaryValues : true,
items: {
path: "f4>/Agreement_AgentsSet",
template: oActionAgentItemTemplate,
templateShareable: "false"}
}).bindProperty("value", "AgrAgentidTo");
var oSaveButton = new sap.ui.commons.Button({
text: "Save",
press: function (oEvent) {
oModel.submitChanges({
success: function(oData, sResponse) {
},
error: function(oError) {
jQuery.sap.log.error("oData Failure", oError);
}
});
oEvent.getSource().getParent().close();
}
});
var oCancelButton = new sap.ui.commons.Button({
text: "Cancel",
press: function (oEvent) {
oModel.resetChanges();
oEvent.getSource().getParent().close();
}
});
oActionEditDialog.addContent(sAgrId);
oActionEditDialog.addContent(iAgrId);
oActionEditDialog.addContent(sAgrActionid);
oActionEditDialog.addContent(iAgrActionid);
oActionEditDialog.addContent(sCreatedBy);
oActionEditDialog.addContent(iCreatedBy);
oActionEditDialog.addContent(sCreatedOn);
oActionEditDialog.addContent(iCreatedOn);
oActionEditDialog.addContent(sActionComment);
oActionEditDialog.addContent(iActionComment);
oActionEditDialog.addContent(sAgrActionDate);
oActionEditDialog.addContent(iAgrActionDate);
oActionEditDialog.addContent(sAgrChaseDate);
oActionEditDialog.addContent(iAgrChaseDate);
oActionEditDialog.addContent(sAgrActtypeid);
oActionEditDialog.addContent(iAgrActtypeid);
oActionEditDialog.addContent(sAgrStatidFrom);
oActionEditDialog.addContent(iAgrStatidFrom);
oActionEditDialog.addContent(sAgrStatidTo);
oActionEditDialog.addContent(iAgrStatidTo);
oActionEditDialog.addContent(sAgrAgentidFrom);
oActionEditDialog.addContent(iAgrAgentidFrom);
oActionEditDialog.addContent(sAgrAgentidTo);
oActionEditDialog.addContent(iAgrAgentidTo);
oActionEditDialog.addContent(oSaveButton);
oActionEditDialog.addContent(oCancelButton);
},
Problem was in the parameter definition in the createEntry method, correct statement below:
var oEntry = oModel.createEntry("/Agreement_ActionsSet", {properties:oNewObject});

Openlayer Linestring with two or more lines on the one or more coordinates?

My problem is the following:
Linestring with two or more lines on the one or more coordinates.
With several LineStrings only one string is shown in the map, I know, the LineStrings also use the same coordinates.
Is there a way that the LineStrings can use one and the same coordinates, but a shift of the line (to have for example three lines next to each other) takes place in the structure of the map?
The code is a bit better, which explains a lot:
var logoElement = document.createElement ('a');
logoElement.href = 'http://www.schienenpost.de/';
logoElement.target = '_blank';
var logoImage = document.createElement ('img');
logoImage.src = 'http://www.schienenpost.de/schienenpost.png';
logoElement.appendChild (logoImage);
var iconStyle = new ol.style.Style ({
image: new ol.style.Icon (/** #type {olx.style.IconOptions} */ ({
anchor: [0.5, 1.0],
src: 'http://www.schienenpost.de/marker/marker.png'
}))
});
var scaleLineControl = new ol.control.ScaleLine();
var markerStartEnd = function (layer,feature) {
var i, iconFeature, iconFeatures = [], coordinates, nameLine;
coordinates = feature.getGeometry ().getCoordinates ();
nameLine = feature.getProperties () ['name'];
i = 0;
iconFeature = new ol.Feature ({
geometry: new ol.geom.Point (coordinates[i]),
name: 'Start'+nameLine,
});
iconFeature.setStyle (iconStyle);
iconFeatures.push (iconFeature);
i = coordinates.length - 1;
iconFeature = new ol.Feature ({
geometry: new ol.geom.Point (coordinates[i]),
name: 'End'+nameLine,
});
iconFeature.setStyle (iconStyle);
iconFeatures.push (iconFeature);
layer.getSource ().addFeatures (iconFeatures);
};
var layerLines = new ol.layer.Vector ({
source: new ol.source.Vector ({
format: new ol.format.GeoJSON (),
url: 'schienenpost.geojson',
useSpatialIndex: false
}),
style: new ol.style.Style ({stroke: new ol.style.Stroke ({color : 'red', width: 3})}),
});
var layerMarker = new ol.layer.Vector ({
title: 'Marker',
source: new ol.source.Vector ()
});
var element = document.getElementById ('popup');
var popup = new ol.Overlay ({
element: element,
positioning: 'bottom-center',
stopEvent: false,
offset: [0, -0]
});
var map = new ol.Map ({
controls: ol.control.defaults ()
.extend ([
new ol.control.OverviewMap (),
new ol.control.FullScreen (),
scaleLineControl
]),
//target 'map',
target: document.getElementById ('map'),
layers: [
new ol.layer.Tile ({
source: new ol.source.OSM ()
}),
],
view: new ol.View ({
center: ol.proj.fromLonLat ([10.627, 53.620]),
zoom: 8
}),
logo: logoElement
});
map.addOverlay (popup);
map.addLayer (layerLines);
map.addLayer (layerMarker);
map.once ('moveend', function(e) {
layerLines.getSource ().getFeaturesCollection ().forEach (function (feature) {
markerStartEnd (layerMarker,feature);
});
});
map.on ('click', function (evt) {
var feature = map.forEachFeatureAtPixel (evt.pixel,
function (feature) {
return feature;
});
if (feature) {
var coordinates = feature.getGeometry ().getCoordinates ();
var clickpoint = map.getCoordinateFromPixel (evt.pixel);
if (!isNaN (coordinates [0])) { // Punkt
popup.setPosition (coordinates);
} else if (!isNaN (coordinates [0][0])) { // Linie
popup.setPosition (clickpoint);
} else { // kein brauchbares feature
$ (element).popover ('destroy');
return;
}
$ (element).popover ({
'placement': 'top',
'html': true,
'content': feature.get ('name')
});
$ (element).popover ().data ('bs.popover').options.content = feature.get ('name');
$ (element).popover ('show');
} else {
$ (element).popover ('hide');
}
});
map.on ('pointermove', function(e) {
if (e.dragging) {
$ (element).popover ('destroy');
return;
}
var pixel = map.getEventPixel (e.originalEvent);
var hit = map.hasFeatureAtPixel (pixel);
map.getTarget ().style.cursor = hit ? 'pointer' : '';
});

How to stub view model in ui5?

I'm new to qunit + sinon.js, I want to write a unit test for function onMultiSelectPress, so I need to mock:
this.myController._oList
this.myController.getResourceBundle()
this.myController.getModel("masterView")
Right?
I'm stuck at get a stub for getModel("masterView"), any suggestion?
onInit : function () {
var oList = this.byId("list"),
oViewModel = this._createViewModel();
this._oList = oList;
this.setModel(oViewModel, "masterView");
},
_createViewModel : function() {
return new JSONModel({
isFilterBarVisible: false,
filterBarLabel: "",
delay: 0,
title: this.getResourceBundle().getText("masterTitleCount", [0]),
noDataText: this.getResourceBundle().getText("masterListNoDataText"),
sortBy: "Name",
groupBy: "None",
listMode: "SingleSelectMaster",
showDeleteButton: false
});
},
getModel : function (sName) {
return this.getView().getModel(sName);
},
onMultiSelectPress : function () {
var oMasterViewModel = this.getModel("masterView");
switch(this._oList.getMode()) {
case "MultiSelect":
oMasterViewModel.setProperty("/listMode", "SingleSelectMaster");
oMasterViewModel.setProperty("/showDeleteButton", false);
break;
case "SingleSelectMaster":
oMasterViewModel.setProperty("/listMode", "MultiSelect");
oMasterViewModel.setProperty("/showDeleteButton", true);
break;
}
},
Add a oViewStub in beforeEach, and set an empty JSON model using for testing.
QUnit.module("MasterController", {
beforeEach: function() {
this.oMasterController = new MasterController();
this.models = {};
var oViewStub = {
setModel: function(model, name) {
this.models[name] = model;
}.bind(this),
getModel: function(name) {
return this.models[name];
}.bind(this)
};
sinon.stub(Controller.prototype, "getView").returns(oViewStub);
},
afterEach: function() {
this.oMasterController.destroy();
jQuery.each(this.models, function(i, model) {
model.destroy();
});
Controller.prototype.getView.restore();
}
});
QUnit.test("test onMultiSelectPress() ", function(assert) {
var oMasterController = this.oMasterController;
var oModel = new JSONModel();
oMasterController.setModel(oModel, "masterView");
var oMasterViewModel = oMasterController.getModel("masterView");
oMasterController._oList = new sap.m.List();
sinon.stub(oMasterController._oList, "getMode").returns("MultiSelect");
oMasterController.onMultiSelectPress();
assert.strictEqual(oMasterViewModel.getProperty("/listMode"), "SingleSelectMaster", "Did change list mode to SingleSelectMaster");
assert.strictEqual(oMasterViewModel.getProperty("/showDeleteButton"), false, "Did hide the delete button");
oMasterController._oList.getMode.restore();
sinon.stub(oMasterController._oList, "getMode").returns("SingleSelectMaster");
oMasterController.onMultiSelectPress();
assert.strictEqual(oMasterViewModel.getProperty("/listMode"), "MultiSelect", "Did change list mode to MultiSelect");
assert.strictEqual(oMasterViewModel.getProperty("/showDeleteButton"), true, "Did show the delete button");
oMasterController._oList.destroy();
});

Call function from controller from within event function of a responsivepopup

I have a responsivepopup containing a list in mode 'Delete'.
When I click to delete an item a function is called on press.
Withing this function 'this' is the oList and oEvent.oSource is also the oList.
From within the event function I need to call a function in my controller.
I can't find a way to reference my controller, not even using sap..core..byId("Detail") or even the full namespace.
I tried walking up the elemnt tree from oEvent.oSource.getParent().getParent() to then call .getController() but it's a dead end.
handlePressViewSelection: function(oEvent) {
var oResourceBundle = this.getResourceBundle();
//create the list
var oList = new sap.m.List({
mode: "Delete",
delete: this.handleDeleteSelectionItem
});
oList.setModel(this._oSelectedTrainingsModel);
var oItemTemplate = new sap.m.StandardListItem({
title : "{Title}",
description : "{=${Begda} ? ${Type} - { path: 'Begda', type: 'sap.ui.model.type.Date', formatOptions: { style: 'medium' }} : ${Type}}",
icon : "{icon}",
iconInset : false
});
oList.bindAggregation("items", {
path: "/",
template: oItemTemplate,
type: "Active"
});
var oBeginButton = new sap.m.Button({
text: "Action1",
type: sap.m.ButtonType.Reject,
press: function(){
oResponsivePopover.setShowCloseButton(false);
}
});
var oEndButton = new sap.m.Button({
text: "Action2",
type: sap.m.ButtonType.Accept,
press: function(){
oResponsivePopover.setShowCloseButton(true);
}
});
var oResponsivePopover = new sap.m.ResponsivePopover({
placement: sap.m.PlacementType.Bottom,
title: "",
showHeader: false,
beginButton: oBeginButton,
endButton: oEndButton,
horizontalScrolling: false,
content: [
oList
]
});
oResponsivePopover.openBy(oEvent.oSource);
},
handleDeleteSelectionItem: function(oEvent) {
var oListItem = oEvent.getParameter('listItem');
var oList = oListItem.getParent();
var path = oListItem.getBindingContext().sPath;
oList.getModel().getData().splice(parseInt(path.substring(1)), 1);
oList.removeItem(oEvent.getParameter('listItem'));
oList.getParent().getParent().getController()._updateViewSelectionButtonText(); //--> BROKEN
},
When you instantiate your popup from a fragment, you can specify "a Controller to be used for event handlers in the Fragment" (see https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.html#.xmlfragment)
For example:
onOpenResponsivePopover : function(oEvent) {
if (!this._oResponsivePopover) {
// adding 'this' makes sure you specify the current controller to be used for event handlers
this._oResponsivePopover = sap.ui.xmlfragment("namespace.to.your.popoverfragment", this);
this.getView().addDependent(this._oResponsivePopover);
}
this._oResponsivePopover.openBy(oEvent.getSource());
},

Extjs 4.0 MVC Add components to a form based on Store

I am ashamed to say I have spent most of today on this. I am trying to build a form based on the contents of an data store. I am using Ext.js and the MVC architecture. Here's what I have:
var myitems = Ext.create('Ext.data.Store', {
fields: ['name', 'prompt', 'type'],
data :
[
{"name":"name", "prompt":"Your name" , "type":"textfield"},
{"name":"addr", "prompt":"Your street address", "type":"textfield"},
{"name":"city", "prompt":"Your city" , "type":"textfield"}
]
});
function genwidget(name, prompt, type)
{
console.log("In genwidget with name=" + name + ", prompt=" + prompt + ", type=" + type + ".");
var widget = null;
if (type == "textfield")
{
// widget = Ext.create('Ext.form.field.Text',
widget = Ext.create('Ext.form.TextField',
{
xtype : 'textfield',
name : name,
fieldLabel: prompt,
labelWidth: 150,
width : 400, // includes labelWidth
allowBlank: false
});
}
else
{
// will code others later
console.log("Unrecongized type [" + type + '] in function mywidget');
}
return widget;
};
function genItems(myitems)
{
console.log("Begin genItems.");
var items = new Ext.util.MixedCollection();
var howMany = myitems.count();
console.log("There are " + howMany + " items.");
for (var i = 0; i < myitems.count(); i++)
{
var name = myitems.getAt(i).get('name');
var prompt = myitems.getAt(i).get('prompt');
var type = myitems.getAt(i).get('type');
var widget = genwidget(name, prompt, type) ;
items.add(widget);
console.log("items.toString(): " + items.toString());
}
return items;
};
Ext.define('MyApp.view.dynamicform.Form' ,{
extend: 'Ext.form.Panel',
alias : 'widget.dynamicformform',
// no store
title: 'Dynamic Form',
id: 'dynamicform.Form',
bodyPadding: 5,
autoScroll: true,
layout: 'auto',
defaults:
{
anchor: '100%'
},
dockedItems: [ ],
items: genItems(myitems),
// Reset and Submit buttons
buttons: [
{
text: 'Reset',
handler: function()
{
this.up('form').getForm().reset();
console.log('Reset not coded yet');
}
},
{
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function()
{
var form = this.up('form').getForm();
if (form.isValid())
{
form.submit({
success: function(form, action)
{
console.log('Success not coded yet');
}
});
}
}
} // end submit
], // end buttons
initComponent: function()
{
console.log("--> in dynamicform init");
this.callParent(arguments);
console.log("--> leaving dynamicform init");
}
}); // Ext.define
The error I am getting (I've had many throughout the day) is "my.items.push is not a function".
Thanks in advance for any help you can offer!
items is expected to be an array not MixedCollection. It is changed to MixedCollection later on if I remember good. So to fix your issue change:
var items = new Ext.util.MixedCollection();
// ...
items.add(widget);
to
var items = [];
// ...
items.push(widget);
Consider as well defining items of form as an empty array and then in initComponent make use of Ext.apply:
var me = this,
items = genItems(myitems);
Ext.apply(me, {
items:items
});