I have a strange problem with one of my lists. I'll try to explain it clearly but its a little complicated:
1. I have a list called "PHOTO_LIST" which has 4 fields: Id, name, overview and image.
2. It is a child of another list called "ASSET_LIST".
3. PHOTO_LIST has a detail view which consists of 3 UX controls: photo_name (textarea), photo_overview (checkbox) and photo_image (image)
3. In the db, photo_name is a char field, photo_overview is a tinyint and photo_image is a medium blob.
This is the problem:
- everything works fine when I'm online (that is, there is a connection to the server). I can add a new image with a name and tick or not tick the overview. (the values for overview are either true or false, displayed as 'T' or 'F'. So when I add the first image, the overview box is ticked by default. I can add a second image, and if I tick the 'overview' checkbox, when I hit the save button there is some code that runs that will check all the rows in the PHOTO_LIST, and if it is set to 'T', it will change it to 'F' by using the method "updateTableRow". So only one row can have the overview set to 'T' at any time - all the rest should be set to 'F'.
- however, when I stop the server, that is, simulate a disconnect, I get this strange problem happening. If I add more than one image: say I add the first image which by default has the overview field ticked, and then add a second image and manually tick the overview field, then when I come back online and sync up the list with the server, I get an erroneous row inserted in the list between the first and second rows. It seems to be related to the code that sets the overview field because when I comment it out, the problem doesn't happen (of course the check to ensure only one overview is checked doesn't happen, so this is not ideal).
Here is that piece of code:
So if I'm online, I will do a .saveListsEdits straight away. If I'm offline, I have a "Sync" button which basically does a .saveListEdits (when back online).
I've included an image of what the list looks like when I have this problem:
photo list problem.PNG
1. I have a list called "PHOTO_LIST" which has 4 fields: Id, name, overview and image.
2. It is a child of another list called "ASSET_LIST".
3. PHOTO_LIST has a detail view which consists of 3 UX controls: photo_name (textarea), photo_overview (checkbox) and photo_image (image)
3. In the db, photo_name is a char field, photo_overview is a tinyint and photo_image is a medium blob.
This is the problem:
- everything works fine when I'm online (that is, there is a connection to the server). I can add a new image with a name and tick or not tick the overview. (the values for overview are either true or false, displayed as 'T' or 'F'. So when I add the first image, the overview box is ticked by default. I can add a second image, and if I tick the 'overview' checkbox, when I hit the save button there is some code that runs that will check all the rows in the PHOTO_LIST, and if it is set to 'T', it will change it to 'F' by using the method "updateTableRow". So only one row can have the overview set to 'T' at any time - all the rest should be set to 'F'.
- however, when I stop the server, that is, simulate a disconnect, I get this strange problem happening. If I add more than one image: say I add the first image which by default has the overview field ticked, and then add a second image and manually tick the overview field, then when I come back online and sync up the list with the server, I get an erroneous row inserted in the list between the first and second rows. It seems to be related to the code that sets the overview field because when I comment it out, the problem doesn't happen (of course the check to ensure only one overview is checked doesn't happen, so this is not ideal).
Here is that piece of code:
Code:
var oview = {dialog.Object}.getValue('photo_overview'); if (oview == true) { for (var i=0;i < lObj._rData.length; i++) { if ({dialog.object}.getValue('list::PHOTO_LIST::overview', i)== 'T' || {dialog.object}.getValue('list::PHOTO_LIST::overview', i)== true) { lObj.updateTableRow(i,{overview: false}); } } lObj.refresh(); } lObj.updateListFromUXControls(); if (window.online == true) { {dialog.object}.saveListEdits('PHOTO_LIST',{rows: 'allRows'}); }
So if I'm online, I will do a .saveListsEdits straight away. If I'm offline, I have a "Sync" button which basically does a .saveListEdits (when back online).
I've included an image of what the list looks like when I have this problem:
photo list problem.PNG
Comment