TypeError: module.PosModel is undefined - javascript
I inherited on the point_of_sale models.js file in order to add a model. This by following code:
openerp.dewieuw = function(instance, local) { //module is instance.point_of_sale
var module = instance.point_of_sale;
var QWeb = instance.web.qweb;
var _t = instance.web._t;
var round_di = instance.web.round_decimals;
var round_pr = instance.web.round_precision
alert(instance.point_of_sale)
alert(module)
module.PosModel = module.PosModel.extend({
models: [
{
model: 'res.users',
fields: ['name','company_id'],
ids: function(self){ return [self.session.uid]; },
loaded: function(self,users){ self.user = users[0]; },
},{
model: 'res.company',
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id', 'tax_calculation_rounding_method'],
ids: function(self){ return [self.user.company_id[0]] },
loaded: function(self,companies){ self.company = companies[0]; },
},{
model: 'decimal.precision',
fields: ['name','digits'],
loaded: function(self,dps){
self.dp = {};
for (var i = 0; i < dps.length; i++) {
self.dp[dps[i].name] = dps[i].digits;
}
},
},{
model: 'product.uom',
fields: [],
domain: null,
loaded: function(self,units){
self.units = units;
var units_by_id = {};
for(var i = 0, len = units.length; i < len; i++){
units_by_id[units[i].id] = units[i];
units[i].groupable = ( units[i].category_id[0] === 1 );
units[i].is_unit = ( units[i].id === 1 );
}
self.units_by_id = units_by_id;
}
},{
model: 'res.users',
fields: ['name','ean13'],
domain: null,
loaded: function(self,users){ self.users = users; },
},{
model: 'res.partner',
fields: ['name','street','city','state_id','country_id','vat','phone','zip','mobile','email','ean13','write_date','nieuwsbrief','klantgroep','lang'],
domain: [['customer','=',true]],
loaded: function(self,partners){
self.partners = partners;
self.db.add_partners(partners);
},
},{
model: 'res.lang',
fields: ['name', 'code'],
loaded: function(self,langs){
self.langs = langs;
},
},{
model: 'klantgroep',
fields: ['name'],
loaded: function(self,klantgroepen){
self.klantgroepen = klantgroepen;
},
},{
model: 'res.country',
fields: ['name'],
loaded: function(self,countries){
self.countries = countries;
self.company.country = null;
for (var i = 0; i < countries.length; i++) {
if (countries[i].id === self.company.country_id[0]){
self.company.country = countries[i];
}
}
},
},{
model: 'account.tax',
fields: ['name','amount', 'price_include', 'include_base_amount', 'type', 'child_ids', 'child_depend', 'include_base_amount'],
domain: null,
loaded: function(self, taxes){
self.taxes = taxes;
self.taxes_by_id = {};
_.each(taxes, function(tax){
self.taxes_by_id[tax.id] = tax;
});
_.each(self.taxes_by_id, function(tax) {
tax.child_taxes = {};
_.each(tax.child_ids, function(child_tax_id) {
tax.child_taxes[child_tax_id] = self.taxes_by_id[child_tax_id];
});
});
},
},{
model: 'pos.session',
fields: ['id', 'journal_ids','name','user_id','config_id','start_at','stop_at','sequence_number','login_number'],
domain: function(self){ return [['state','=','opened'],['user_id','=',self.session.uid]]; },
loaded: function(self,pos_sessions){
self.pos_session = pos_sessions[0];
var orders = self.db.get_orders();
for (var i = 0; i < orders.length; i++) {
self.pos_session.sequence_number = Math.max(self.pos_session.sequence_number, orders[i].data.sequence_number+1);
}
},
},{
model: 'pos.config',
fields: [],
domain: function(self){ return [['id','=', self.pos_session.config_id[0]]]; },
loaded: function(self,configs){
self.config = configs[0];
self.config.use_proxy = self.config.iface_payment_terminal ||
self.config.iface_electronic_scale ||
self.config.iface_print_via_proxy ||
self.config.iface_scan_via_proxy ||
self.config.iface_cashdrawer;
self.barcode_reader.add_barcode_patterns({
'product': self.config.barcode_product,
'cashier': self.config.barcode_cashier,
'client': self.config.barcode_customer,
'weight': self.config.barcode_weight,
'discount': self.config.barcode_discount,
'price': self.config.barcode_price,
});
if (self.config.company_id[0] !== self.user.company_id[0]) {
throw new Error(_t("Error: The Point of Sale User must belong to the same company as the Point of Sale. You are probably trying to load the point of sale as an administrator in a multi-company setup, with the administrator account set to the wrong company."));
}
},
},{
model: 'stock.location',
fields: [],
ids: function(self){ return [self.config.stock_location_id[0]]; },
loaded: function(self, locations){ self.shop = locations[0]; },
},{
model: 'product.pricelist',
fields: ['currency_id'],
ids: function(self){ return [self.config.pricelist_id[0]]; },
loaded: function(self, pricelists){ self.pricelist = pricelists[0]; },
},{
model: 'res.currency',
fields: ['symbol','position','rounding','accuracy'],
ids: function(self){ return [self.pricelist.currency_id[0]]; },
loaded: function(self, currencies){
self.currency = currencies[0];
if (self.currency.rounding > 0) {
self.currency.decimals = Math.ceil(Math.log(1.0 / self.currency.rounding) / Math.log(10));
} else {
self.currency.decimals = 0;
}
},
},{
model: 'product.packaging',
fields: ['ean','product_tmpl_id'],
domain: null,
loaded: function(self, packagings){
self.db.add_packagings(packagings);
},
},{
model: 'pos.category',
fields: ['id','name','parent_id','child_id','image'],
domain: null,
loaded: function(self, categories){
self.db.add_categories(categories);
},
},{
model: 'product.product',
fields: ['display_name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13', 'default_code',
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description',
'product_tmpl_id'],
domain: [['sale_ok','=',true],['available_in_pos','=',true]],
context: function(self){ return { pricelist: self.pricelist.id, display_default_code: false }; },
loaded: function(self, products){
self.db.add_products(products);
},
},{
model: 'account.bank.statement',
fields: ['account_id','currency','journal_id','state','name','user_id','pos_session_id'],
domain: function(self){ return [['state', '=', 'open'],['pos_session_id', '=', self.pos_session.id]]; },
loaded: function(self, bankstatements, tmp){
self.bankstatements = bankstatements;
tmp.journals = [];
_.each(bankstatements,function(statement){
tmp.journals.push(statement.journal_id[0]);
});
},
},{
model: 'account.journal',
fields: [],
domain: function(self,tmp){ return [['id','in',tmp.journals]]; },
loaded: function(self, journals){
self.journals = journals;
// associate the bank statements with their journals.
var bankstatements = self.bankstatements;
for(var i = 0, ilen = bankstatements.length; i < ilen; i++){
for(var j = 0, jlen = journals.length; j < jlen; j++){
if(bankstatements[i].journal_id[0] === journals[j].id){
bankstatements[i].journal = journals[j];
}
}
}
self.cashregisters = bankstatements;
},
},{
label: 'fonts',
loaded: function(self){
var fonts_loaded = new $.Deferred();
// Waiting for fonts to be loaded to prevent receipt printing
// from printing empty receipt while loading Inconsolata
// ( The font used for the receipt )
waitForWebfonts(['Lato','Inconsolata'], function(){
fonts_loaded.resolve();
});
// The JS used to detect font loading is not 100% robust, so
// do not wait more than 5sec
setTimeout(function(){
fonts_loaded.resolve();
},5000);
return fonts_loaded;
},
},{
label: 'pictures',
loaded: function(self){
self.company_logo = new Image();
var logo_loaded = new $.Deferred();
self.company_logo.onload = function(){
var img = self.company_logo;
var ratio = 1;
var targetwidth = 300;
var maxheight = 150;
if( img.width !== targetwidth ){
ratio = targetwidth / img.width;
}
if( img.height * ratio > maxheight ){
ratio = maxheight / img.height;
}
var width = Math.floor(img.width * ratio);
var height = Math.floor(img.height * ratio);
var c = document.createElement('canvas');
c.width = width;
c.height = height
var ctx = c.getContext('2d');
ctx.drawImage(self.company_logo,0,0, width, height);
self.company_logo_base64 = c.toDataURL();
logo_loaded.resolve();
};
self.company_logo.onerror = function(){
logo_loaded.reject();
};
self.company_logo.crossOrigin = "anonymous";
self.company_logo.src = '/web/binary/company_logo' +'?_'+Math.random();
return logo_loaded;
},
},
],
});
module.ClientListScreenWidget = module.ClientListScreenWidget.extend({
// what happens when we save the changes on the client edit form -> we fetch the fields, sanitize them,
// send them to the backend for update, and call saved_client_details() when the server tells us the
// save was successfull.
save_client_details: function(partner) {
var self = this;
var fields = {}
this.$('.client-details-contents .detail').each(function(idx,el){
fields[el.name] = el.value;
if(el.name=='nieuwsbrief'){
fields[el.name] = el.checked;
}
});
if (!fields.name) {
this.pos_widget.screen_selector.show_popup('error',{
message: _t('A Customer Name Is Required'),
});
return;
}
if (this.uploaded_picture) {
fields.image = this.uploaded_picture;
}
fields.id = partner.id || false;
fields.country_id = fields.country_id || false;
fields.ean13 = fields.ean13 ? this.pos.barcode_reader.sanitize_ean(fields.ean13) : false;
new instance.web.Model('res.partner').call('create_from_ui',[fields]).then(function(partner_id){
self.saved_client_details(partner_id);
},function(err,event){
event.preventDefault();
self.pos_widget.screen_selector.show_popup('error',{
'message':_t('Error: Could not Save Changes'),
'comment':_t('Your Internet connection is probably down.'),
});
});
},
});
}
This worked like a charm. But now I wanted to inherit on the website_sale.js file so I added some test code to this file. And now I always get this error:
TypeError: module.PosModel is undefined
I deleted this test code, but still the error occurs. Any ideas? I also placed my whole module back to a backup were everything worked fine, but I'm still getting this error.
Have you added point_of_sale dependency in website_sale module openerp.py file ?
If not, please add it and try again.
Related
Group key value objects
I have an array of objects (pre_finalTab_new below) like this: My goal is to group them by "schema", and then by "tip" and insert into new array, something like this: var celotnaTabela = {}; for (var nov in pre_finalTab_new) { var shema = pre_finalTab_new[nov].schema.trim(); var objekt_tip = pre_finalTab_new[nov].type.trim(); var objekt_name = pre_finalTab_new[nov].name.trim(); var tip = pre_finalTab_new[nov].tip.trim(); if (celotnaTabela[shema] === undefined) { celotnaTabela[shema] = []; if (celotnaTabela[shema][tip] === undefined) { celotnaTabela[shema][tip] = []; if (celotnaTabela[shema][tip][objekt_tip] === undefined) { celotnaTabela[shema][tip][objekt_tip] = []; celotnaTabela[shema][tip][objekt_tip] = [objekt_name]; } else celotnaTabela[shema][tip][objekt_tip].push(objekt_name); } } else { if (celotnaTabela[shema][tip] === undefined) { celotnaTabela[shema][tip] = []; } if (celotnaTabela[shema][tip][objekt_tip] === undefined) { celotnaTabela[shema][tip][objekt_tip] = []; celotnaTabela[shema][tip][objekt_tip] = [objekt_name]; } else { if (!celotnaTabela[shema][tip][objekt_tip].includes(objekt_name)) celotnaTabela[shema][tip][objekt_tip].push(objekt_name); } } } Then if i output celotnaTabela, i got this: Expanded: Even more: But the problem is, when i try to use JSON.stringify(celotnaTabela), i got this: {"HR":[],"ZOKI":[]} But i need it to be in a right format, so i can pass this object into AJAX call.. Can anyone help me with this, what am i doing wrong?
i hope i understood everything right you asked for. Next time provide the testdata and the wished result in textform pls. var obj = [ { schema: "HR", type: " PACKAGE", name: "PAKET1", tip: "new_objects" }, { schema: "HR", type: " PACKAGE", name: "PAKET2", tip: "new_objects" }, { schema: "HR", type: " PROCEDURE", name: "ADD_JOB_HISTORY", tip: "new_objects" }, { schema: "ZOKI", type: " TABLE", name: "TABELA2", tip: "new_objects" }, { schema: "ZOKI", type: " TABLE", name: "TABELA3", tip: "new_objects" }, ]; var out = {}; for (var i = 0, v; v = obj[i]; i++) { var a = v.schema.trim(); var b = v.type.trim(); var c = v.tip.trim(); var d = v.name.trim(); if (!out.hasOwnProperty(a)) { out[a] = {}; } if (!out[a].hasOwnProperty(b)) { out[a][b] = {}; } if (!out[a][b].hasOwnProperty(c)) { out[a][b][c] = [] } out[a][b][c].push(d); } console.log(JSON.stringify(out, null, 2));
JavaScript - How to make matching game cards stay flipped over after click
I found this matching game on codepen.io that I am using in corporation with a trivia spinner - thanks #Malky.kid - The idea is once they get to the matching game they have 10 clicks to match as many as they can but the cards MUST stay flipped over. This is for a project and the odds of winning has to do with chance not skill. (function(){ var Memory = { init: function(cards){ this.$game = $(".game"); this.$modal = $(".modal"); this.$overlay = $(".modal-overlay"); this.$restartButton = $("button.restart"); this.cardsArray = $.merge(cards, cards); this.shuffleCards(this.cardsArray); this.setup(); }, shuffleCards: function(cardsArray){ this.$cards = $(this.shuffle(this.cardsArray)); }, setup: function(){ this.html = this.buildHTML(); this.$game.html(this.html); this.$memoryCards = $(".card"); this.binding(); this.paused = false; this.guess = null; }, binding: function(){ this.$memoryCards.on("click", this.cardClicked); this.$restartButton.on("click", $.proxy(this.reset, this)); }, // kinda messy but hey cardClicked: function(){ var _ = Memory; var $card = $(this); if(!_.paused && !$card.find(".inside").hasClass("matched") && !$card.find(".inside").hasClass("picked")){ $card.find(".inside").addClass("picked"); if(!_.guess){ _.guess = $(this).attr("data-id"); } else if(_.guess == $(this).attr("data-id") && !$(this).hasClass("picked")){ $(".picked").addClass("matched"); _.guess = null; } else { _.guess = null; _.paused = true; setTimeout(function(){ $(".picked").removeClass("picked"); Memory.paused = false; }, 600); } if($(".matched").length == $(".card").length){ _.win(); } } }, win: function(){ this.paused = true; setTimeout(function(){ Memory.showModal(); Memory.$game.fadeOut(); }, 1000); }, showModal: function(){ this.$overlay.show(); this.$modal.fadeIn("slow"); }, hideModal: function(){ this.$overlay.hide(); this.$modal.hide(); }, reset: function(){ this.hideModal(); this.shuffleCards(this.cardsArray); this.setup(); this.$game.show("slow"); }, // Fisher--Yates Algorithm -- https://bost.ocks.org/mike/shuffle/ shuffle: function(array){ var counter = array.length, temp, index; // While there are elements in the array while (counter > 0) { // Pick a random index index = Math.floor(Math.random() * counter); // Decrease counter by 1 counter--; // And swap the last element with it temp = array[counter]; array[counter] = array[index]; array[index] = temp; } return array; }, buildHTML: function(){ var frag = ''; this.$cards.each(function(k, v){ frag += '<div class="card" data-id="'+ v.id +'"><div class="inside">\ <div class="front"><img src="'+ v.img +'"\ alt="'+ v.name +'" /></div>\ <div class="back"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/codepen-logo.png"\ alt="Codepen" /></div></div>\ </div>'; }); return frag; } }; var cards = [ { name: "php", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/php-logo_1.png", id: 1, }, { name: "css3", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/css3-logo.png", id: 2 }, { name: "html5", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/html5-logo.png", id: 3 }, { name: "jquery", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/jquery-logo.png", id: 4 }, { name: "javascript", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/js-logo.png", id: 5 }, { name: "node", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/nodejs-logo.png", id: 6 }, { name: "photoshop", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/photoshop-logo.png", id: 7 }, { name: "python", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/python-logo.png", id: 8 }, { name: "rails", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/rails-logo.png", id: 9 }, { name: "sass", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/sass-logo.png", id: 10 }, { name: "sublime", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/sublime-logo.png", id: 11 }, { name: "wordpress", img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/74196/wordpress-logo.png", id: 12 }, ]; Memory.init(cards); })(); see game here The only difference to this is that the cards stay flipped over - if they match cards they should still show that they are matched - it highlights green for a second. The cards flip back over after you select two cards ONLY if they do not match. If they do match they stay facing up but I need it always facing up. Thanks
Dijit Selects, Items in the Combobox disabled = true doesn't works
This is my code and it doesn't works. It belong to a combobox. Some items should be disabled in it. var data = []; for (i = 0; i < items.length; i++) { data.push({id: items[i].id, label: "foobaa"}); data.getOptions(items[i].id).disabled = true; } var memory = new Memory({ idProperty: "id", data: data }); this._widget.set("store", memory); I found a code snipe at fiddle.net and this works but im not able to converte it to my problem. http://jsfiddle.net/g00glen00b/akcZy/ Also the otherwise super documentation of dojo doesn't helps me :-( http://dojotoolkit.org/documentation/tutorials/1.10/selects_using_stores/
I have made some changes try this and let me know is this your need? Use the code below to disable all the select items. var data = []; for (i = 0; i < myData.length; i++) { data.push('{id: myData[i].id, label: "foobaa"}'); registry.byId("mySelect").getOptions(myData[i].id).disabled = true; } http://jsfiddle.net/f3snxrrd/ http://jsfiddle.net/5pgkkf0z/
items: { mutators: { value: [], type: verify.ARRAY }, widget: { updateI18n: true, mapping: function (widget, items) { if (this._widget) { var i; var data = []; for (i = 0; i < items.length; i++) { data.push({id: items[i].id, label: i18n.resolveSequence(items[i].label)}); //register.byId(data).getOptions((items[i].value).disabled = true); } var memory = new Memory({ idProperty: "id", data: data }); this._widget.set("store", memory); this._widget.closeDropDown(true); this._widget.reset(); if (items.length === 0) { this._enabledItems = false; } else if (items.length === 1) { this.set("selectedId", items[0].id); this._enabledItems = (this.get("selectedId") !== items[0].id); } else { this._enabledItems = true; } this._widget.set("disabled", !(this._enabledState && this._enabledItems )); } } } }, _createWidget: function () { var ret; ret = new Select({id: this.uniqueId, disabled: true, labelAttr: "label", labelType: "Text", required: false, store: new Memory({data: []})}); var that = this; ret.own(on(ret, "change", function (value) {that._onChange(value); })); return ret; },
This is the items array: The code from jsfiddle.net http://jsfiddle.net/8m52n81u/11/ I can't change the items array :-/ items = [{ id: "0", label: key[{0: "foo", 1: "baa"}] }, { id: "1", label: key[{0: "foo", 1: "baa"}] }]; require([ "dojo/ready", "dijit/registry", "dijit/form/Select", "dojo/store/Memory", "dojo/parser" ], function(ready, registry) { ready(function() { var data = []; for (i = 0; i < items.length; i++) { data.push('{id: items[i].id, label: items[i].label}'); registry.byId("uniqueId").getOptions(items[i].id).disabled = true; } }); });
Karma unit testing of controller using service. Ionic app
I'm new to Ionic and trying to test my controller which is using a service but keep getting 'undefined' with '$scope.order', '$scope.stock' and all the functions included in my controller. I have tested the service separately all tests passing there but can't get my head around controller testing. I'm sure I'm doing something wrong. Would be grateful is somebody could guide me a little bit. controller.js angular.module('shop.controllers', []) .controller('StockCtrl', function($scope, Stock) { $scope.stock = Stock.all(); $scope.order = Stock.order(); $scope.showTotalPrice = function() { $scope.total = Stock.total(); } $scope.addToBasket = function(chatId){ Stock.update(chatId); Stock.updateBasket(chatId); } }); service.js angular.module('shop.services', []) .factory('Stock', function() { var order = []; var prices = []; var total = 0; var items = [{ id: 0, name: "Black Shoes", price: 50, quantity: 7 }, { id: 1, name: "Blue Shoes", price: 10, quantity: 2 }, { id: 2, name: "Green Shoes", price: 14, quantity: 5 }, { id: 3, name: "Red Flip Flops", price: 9, quantity: 6 } }]; return { all: function() { return items; }, get: function(itemId) { for (var i = 0; i < items.length; i++) { if (items[i].id === parseInt(itemId)) { return items[i]; } } return null; }, update: function(itemId) { for (var i = 0; i < items.length; i++) { if (items[i].id === parseInt(itemId)) { return items[i].quantity -= 1; } } return null; }, updateBasket: function(itemId) { for (var i = 0; i < items.length; i++) { if (items[i].id === parseInt(itemId)) { order.push({name: items[i].name, price: items[i].price}); prices.push(items[i].price); } } return null; }, order: function() { return order; }, total: function() { return total = eval(prices.join('+')); }, }; }); controller.spec.js describe('Controllers', function(){ var scope; var control; var StockMock; beforeEach(module('shop.controllers')); beforeEach(function(){ StockMock = jasmine.createSpyObj('Stock', ['all', 'get', 'update', 'updateBasket', 'order']) inject(function($rootScope, $controller){ scope = $rootScope.$new(); control = $controller('StockCtrl', {$scope: scope, Stock: StockMock}); }); }); it("should have a scope variable defined", function() { expect(scope).toBeDefined(); }); });
I think your problem is here: beforeEach(module('shop.controllers')); You should add the application module instead of controller module. beforeEach(module('shop'));
How can I resize Jira gadgets' data?
I am implementing a Jira gadget. I have an problem about retrieve data. I am retrieving data from DB to gadget. There are lots of columns so the gadget cannot show all columns. I guess I have to resize data. There is one more thing; how can I stop the retrieving data to go end of pages? Here is my gadget.xml #requireResource("com.atlassian.gadgets.publisher:ajs-gadgets") #requireResource("sqlGadget:Web-resources") #requireResource("com.atlassian.jira.gadgets:common") #requireResource("com.atlassian.jira.gadgets:autocomplete") #includeResources() <script type="text/javascript"> (function () { var gadget = AJS.Gadget({ baseUrl: "__ATLASSIAN_BASE_URL__", useOauth: "/rest/gadget/1.0/currentUser", config: { descriptor: function(args) { var gadget = this; gadgets.window.setTitle("SQL Gadget Config"); var projectPicker = AJS.gadget.fields.projectPicker(gadget, "projectId", args.projectOptions); return { fields: [ projectPicker, { id: "configNumber-id", userpref: "configNumber", label: "Config number", description: "", type: "select", selected: gadget.getPref("configNumber"), options: [ { label:"1", value:"1" }, { label:"2", value:"2" }, { label:"3", value:"3" } ] }, AJS.gadget.fields.nowConfigured() ] }; }, args: function() { return [ { key: "projectOptions", ajaxOptions: "/rest/gadget/1.0/filtersAndProjects?showFilters=false" } ]; }() }, view: { /* HTML PART*/ onResizeAdjustHeight: true, enableReload: true, template: function (args) { var gadget = this; var response = args.projects.value; AJS.$.each(AJS.$.parseJSON(response), function(idx, obj) { console.log(obj); }); var myList=AJS.$.parseJSON(response); var test="<body onLoad=buildHtmlTable()><table id=excelDataTable border=1> </table></body>"; document.getElementById("myDiv").innerHTML = test; var columns = addAllColumnHeaders(myList); for (var i = 0 ; i < myList.length ; i++) { var row$ = AJS.$('<tr/>'); for (var colIndex = 0 ; colIndex < columns.length ; colIndex++) { var cellValue = myList[i][columns[colIndex]]; if (cellValue == null) { cellValue = ""; } row$.append(AJS.$('<td/>').html(cellValue)); } AJS.$("#excelDataTable").append(row$); } function addAllColumnHeaders(myList) { var columnSet = []; var headerTr$ = AJS.$('<tr/>'); for (var i = 0 ; i < myList.length ; i++) { var rowHash = myList[i]; for (var key in rowHash) { if (AJS.$.inArray(key, columnSet) == -1){ columnSet.push(key); headerTr$.append(AJS.$('<th/>').html(key)); } } } AJS.$("#excelDataTable").append(headerTr$); return columnSet; } }, args: [ { key: "projects", ajaxOptions: function () { var projectName; var confOrder; var projectField = document.getElementById("projectId"); var confNumbElement = document.getElementById("configNumber-id"); if(projectField != null){ projectName = projectField.options[projectField.selectedIndex].text; console.log(projectName); } if(confNumbElement != null){ confOrder = confNumbElement.options[confNumbElement.selectedIndex].text; console.log(confOrder); this.configNumber = confOrder; } return { url: "/rest/sqlrestsource/latest/execute", data: { projectId : gadgets.util.unescapeString(this.getPref("projectId")), configNumber : gadgets.util.unescapeString(this.getPref("configNumber")), } }; } } ] } }); })();