friends.
I have ionic V1 application with 2 tabs, add and list. And for persist the data, I use SQLite.
My problem.
In add tab, I insert data in database perfectly, but, when I redirect to list, the last that i insert, doesn't display on list
arrList = []
db.transaction(function (tx)
{
var query_users = "SELECT * FROM users";
tx.executeSql(query_users, [], function (tx, results)
{
var len = results.rows.length;
for (var i = 0; i < len; i++) {
arrList.push(results.rows[i]);
}
}, null);
});
$scope.userList = arrList;
What is my mistake?
for (var i = 0; i < len; i++)
{
$scope.arrList.push({id: result.rows.item(i).id, message:
result.rows.item(i).message});
}
i used to push data in this way..
ie is... result.rows.item(i).["variable name"]
may be it will help u...
Related
I try to populate a google forms multipleChoiceItem with a lot of Item from my google sheet AND also configure the pagebreak (conditionnal answers) from my google sheet
EDIT: There Is my code, Hope it is easier to understand my problem
function AutoPopulateGF() {
var form = FormApp.openById("1fyej6DSh2B1spsurOR-gnD5s1NWrekt4Sf8xiIL7EjY");
var items = form.getItems();
var ss = SpreadsheetApp.openById("1hEBCEvUqJHnRuRqZS0FmhOZhOKG4PMa83czvdn01qcM").getSheetByName("Remplir ICI")
var data = ss.getDataRange().getValues();
var numrows = ss.getDataRange().getLastRow()
for (var i in items) {
if (items[i].getTitle() == 'Choisissez le module ') {
/*
//THIS BELOW IS NOT WORKING
items[i].asMultipleChoiceItem().setChoices([
for (var j = 0; j < numrows; ++j) {
var column = data[j];
if (column[0] != "") {
items[i].asMultipleChoiceItem().createChoice(column[0],form.getItemById(column[30]).asPageBreakItem()),
}
}
])
*/
//THIS WORKS BUT VERY TIME CONSUMMING... (I HAVE MORE THAN 200 LINES)
items[i].asMultipleChoiceItem().setChoices([
items[i].asMultipleChoiceItem().createChoice(ss.getRange("A70").getValues(),form.getItemById(ss.getRange("AD70").getValues()).asPageBreakItem()),
items[i].asMultipleChoiceItem().createChoice(ss.getRange("A71").getValues(),form.getItemById(ss.getRange("AD71").getValues()).asPageBreakItem()),
items[i].asMultipleChoiceItem().createChoice(ss.getRange("A72").getValues(),form.getItemById(ss.getRange("AD72").getValues()).asPageBreakItem()),
items[i].asMultipleChoiceItem().createChoice(ss.getRange("A73").getValues(),form.getItemById(ss.getRange("AD73").getValues()).asPageBreakItem()),
items[i].asMultipleChoiceItem().createChoice(ss.getRange("A74").getValues(),form.getItemById(ss.getRange("AD74").getValues()).asPageBreakItem())
])
}
}
}
How to Automate the process ?
Thanks for your help!
I've written out a block of code that allows the user to check or uncheck entities that will be added or removed via web services. My add function seems to be working correctly and provides the ability to add multiple entities. However, my delete function isn't working the same. It doesn't delete each time, and can only delete one at a time. I'm struggling since the code is effectively the same as the add, so I don't know if the issue is AngularJS related or perhaps my web service isn't working correctly.
Edit: I've actually noticed that the for loop goes through it all but doesn't select the correct id, it always starts from the first one.
var toDeleteService = [];
for (var i = 0; i < $scope.siteServices.length; i++) {
if ($scope.siteServices[i].chosen != $scope.siteServices[i].origChosen) {
if ($scope.siteServices[i].chosen == true) {
toAddService.push(i);
}
else {
toDeleteService.push(i);
}
}
}
if (toDeleteService.length > 0) {
var deleteRequest = {};
deleteRequest.services = [];
for (var i = 0; i < toDeleteService.length; i++) {
var parentServiceName = $scope.siteServices[i].parentServiceName;
var j = 0;
for (; j < deleteRequest.services.length; j++) {
if (deleteRequest.services[j].parentServiceName == parentServiceName) {
break;
}
}
if (j == deleteRequest.services.length) {
deleteRequest.services[j] = {};
deleteRequest.services[j].parentServiceName = parentServiceName;
deleteRequest.services[j].subservices = [];
}
var service = {};
service.serviceId = $scope.siteServices[i].serviceId;
deleteRequest.services[j].subservices.push(service);
}
var deleteUrl = "api/sites/" + $scope.targetEntity.siteId + "/services/" + service.serviceId;
$http.delete(deleteUrl)
.then(function (response) {
});
}
As I understood it you are trying to remove siteServices based by numbers stored in var toDeleteServices = [] so you need to access those numbers by its index. but in service.serviceId = $scope.siteServices[i].serviceId; you are using i instead.
service.serviceId = $scope.siteServices[toDeleteServices[i]].serviceId; as you need actual number of the service to delete.
If I understood your code correctly.
I cannot figure out why this http post is returning bad data in console :-
var dataObj = {"id": 21};
$http.post('http://localhost:9099/GetItems', dataObj).then(function(response) {
var size = response.data.length;
for (var i = 0; i < size; i++) {
var list = response.data.split(",");
for (var j = 0; j < list.length; j++) {
var elem = angular.element("#" + s);
elem.style.visible = "block";
}
}
});
I changed GetItems to a different api - this had no problem.
Looks like you are trying to get data from back end belongs to the id.
To get items use get instead of post
Like $http.get('http://localhost:9099/GetItems' + id)
i am currently working with Sencha Touch, Sencha Architect 3,
builded a simple list using a pluing called Pullrefresh:
https://github.com/p5hema2/Sencha-PullRefresh-RefreshFn
I am only able to update records if they are new, but updated and deleted records are on my store, but not updated with my view. So i need to modify my plugin. In Sencha Architect i don't know how to solve that.
Is anyone experienced with that? Modifying plugins
Ext.define('TP.extend.override.PullRefresh', { override: 'Ext.plugin.PullRefresh',
onLatestFetched: function(operation) {
var store = this.getList().getStore(),
oldRecords = store.getData(),
old_length = oldRecords.length,
newRecords = operation.getRecords(),
length = newRecords.length,
toInsert = [],
newRecordIds = [],
oldRecordsArr = [],
toRemove = [],
newRecord, newRecordIndex, oldRecord, i;
for (i = 0; i < length; i++) {
newRecord = newRecords[i];
oldRecord = oldRecords.getByKey(newRecord.getId());
newRecordIds.push(newRecord.getId());
if (oldRecord) {
oldRecord.set(newRecord.getData());
} else {
toInsert.push(newRecord);
}
oldRecord = undefined;
}
store.insert(0, toInsert);
oldRecordsArr = store.getRange();
for (i = 0; i < old_length; i++) {
oldRecord = oldRecordsArr[i];
newRecordIndex = newRecordIds.indexOf(oldRecord.getId());
if (newRecordIndex == undefined || newRecordIndex == -1) {
toRemove.push(oldRecord);
}
oldRecord = undefined;
}
store.remove(toRemove);
}
});
Above example is to update deleted records also.
Below is the code of the internal database table from which I want to display the result in a div
var sear=$("#search").val();
var db = openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
db.transaction(function (tx) {
tx.executeSql("SELECT * FROM DEMO", [],
function (tx, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
$('#output2').append('<tr>td>'+ results.rows.item(i).D_Indications +'</td></tr>');
alert(results.rows.item(i).D_Indications);
}
});
});
I can view the result in alert but I cant view it in the div
Two issues:
table-tag is missing
Typo in call to append(...). Look at opening tags tr td.