I am attempting to use aurelia-slickgrid
as a means to represent tables of data gotten back from an http ajax call.
However, it appears that the slickgrid is firing too soon? I have a response being logged to console that shows my phone list, but the error happens before that.
here is my code:
customer.html:
<template if.bind="phone_list">
<aurelia-slickgrid
grid-id="phoneList"
column-definitions.bind="columnDefinitions"
grid-options.bind="gridOptions"
dataset.bind="phone_list"
grid-height="400"
grid-width="800">
</aurelia-slickgrid>
</template>
customer.js:
async findArisId() {
const self = this;
self.cookie = document.cookie.split("=");
self.user = self.cookie[1];
if ( self.user )
{
var url = 'http://aris2.myaris.net/search.pl';
url += '?REMOTE_USER=' + self.user;
console.log( 'url: ', url );
if ( self.cust_num )
{
var newCustNum = self.cust_num.replace( /#/, '' );
url += '&aris_id=' + newCustNum;
}
if ( self.cust_info )
{
url += '&cust_info=' + self.cust_info;
url += '&cust_info_field=' + self.selectedCustInfo;
}
if ( self.invoice_number )
{
url += '&invoice_number=' + self.invoice_number;
}
if ( self.po_number )
{
url += '&po_number=' + self.po_number;
}
// console.log( 'url', url );
return self.httpClient
.fetch(url)
.then(async (response) => {
let aris_idObj = await response.json();
// console.log( 'response: ', aris_idObj );
this.customerRecord =
await this.getCustomerData(aris_idObj.customerData.aris_id);
if( this.customerRecord )
{
this.status_code_list = await this.statusObj.getStatusCodes(this.customerRecord[0].customer.debtor_id);
this.selectedStatusCode = this.customerRecord[0].customer.status_code;
// PHONE LIST for Slickgrid
self.phone_list = this.customerRecord[3].phone;
console.log('customerRecord[3]', this.customerRecord[3]);
console.log('phone_list', self.phone_list);
//console.log('status_code_list', this.status_code_list);
}
return this.customerRecord;
});
}
}
Of note:
I can’t use bind()
or attached()
as async calls to start the cycle, because I have to have a user enter in a customer number for it to display the record.
I’m unsure how to force slickgrid to init after the phone_list is filled in?
Thanks.