[xwiki-users] Javascript Extension going wrong
Hi community, I'm having a hard time getting a Javascript Extension for an AppWithinMinutes livetable to work. I have several livetable "enhancements" in it like changing background color per field value which work properly. As a reference I've used the example: http://snippets.xwiki.org/xwiki/bin/view/Extension/Background+color+for+a+li... Now I want to change the display of the value of a specific column, for example to display an image or a button next to the value. This works only for the last column in the livetable. All other rows look strange. Example: The simplified code: ``` document.observe("xwiki:livetable:newrow", function(ev){ $$('.sTxtUser').each(function(element){ var content = element.innerText; if(content === undefined){ content = element.textContent; } element.replace('<td class="sTxtUser link typetext" data-title="Username">"' + content + '"</td>') }); }); ``` I have 3 documents for the application with the following values for field sTxtUser : testuser1 test12345 anotheruser1 Using the above extension renders the livetable cells like this: """anotheruser1""" ""test12345"" "testuser1" If I change the sort order: """testuser1""" ""test12345"" "anotheruser1" So only the last row shows the desired output. What am I doing wrong? Regards, Dennis
Hi, Nobody here who can help me fix the Javascript Extension? Regards, Dennis 2016-11-04 14:18 GMT+01:00 D R <[email protected]>:
Hi community,
I'm having a hard time getting a Javascript Extension for an AppWithinMinutes livetable to work.
I have several livetable "enhancements" in it like changing background color per field value which work properly.
As a reference I've used the example: http://snippets.xwiki.org/xwiki/bin/view/Extension/Background+color+for+a+ livetable
Now I want to change the display of the value of a specific column, for example to display an image or a button next to the value. This works only for the last column in the livetable. All other rows look strange.
Example:
The simplified code: ``` document.observe("xwiki:livetable:newrow", function(ev){ $$('.sTxtUser').each(function(element){ var content = element.innerText; if(content === undefined){ content = element.textContent; } element.replace('<td class="sTxtUser link typetext" data-title="Username">"' + content + '"</td>') }); });
```
I have 3 documents for the application with the following values for field sTxtUser : testuser1 test12345 anotheruser1
Using the above extension renders the livetable cells like this: """anotheruser1""" ""test12345"" "testuser1"
If I change the sort order: """testuser1""" ""test12345"" "anotheruser1"
So only the last row shows the desired output.
What am I doing wrong?
Regards, Dennis
On Tue, Nov 8, 2016 at 4:38 PM, D R <[email protected]> wrote:
Hi,
Nobody here who can help me fix the Javascript Extension?
Regards, Dennis
2016-11-04 14:18 GMT+01:00 D R <[email protected]>:
Hi community,
I'm having a hard time getting a Javascript Extension for an AppWithinMinutes livetable to work.
I have several livetable "enhancements" in it like changing background color per field value which work properly.
As a reference I've used the example: http://snippets.xwiki.org/xwiki/bin/view/Extension/ Background+color+for+a+ livetable
Now I want to change the display of the value of a specific column, for example to display an image or a button next to the value. This works only for the last column in the livetable. All other rows look strange.
Example:
The simplified code: ```
document.observe("xwiki:livetable:newrow", function(ev){ $$('.sTxtUser').each(function(element){
Debug your code and you'll see that: * the xwiki:livetable:newrow event is fired for each row in the live table * $$('.sTxtUser') selects all the existing cells So whenever a row is displayed you process not only that row but also the existing rows that have been displayed before..
var content = element.innerText; if(content === undefined){ content = element.textContent; } element.replace('<td class="sTxtUser link typetext" data-title="Username">"' + content + '"</td>') }); });
```
I have 3 documents for the application with the following values for
field
sTxtUser : testuser1 test12345 anotheruser1
Using the above extension renders the livetable cells like this: """anotheruser1""" ""test12345"" "testuser1"
If I change the sort order: """testuser1""" ""test12345"" "anotheruser1"
So only the last row shows the desired output.
What am I doing wrong?
Regards, Dennis
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Thanks Marius, can you tell me how to avoid this and get the desired result or where I can find the information? Regards, Dennis 2016-11-08 18:46 GMT+01:00 Marius Dumitru Florea < [email protected]>:
On Tue, Nov 8, 2016 at 4:38 PM, D R <[email protected]> wrote:
Hi,
Nobody here who can help me fix the Javascript Extension?
Regards, Dennis
2016-11-04 14:18 GMT+01:00 D R <[email protected]>:
Hi community,
I'm having a hard time getting a Javascript Extension for an AppWithinMinutes livetable to work.
I have several livetable "enhancements" in it like changing background color per field value which work properly.
As a reference I've used the example: http://snippets.xwiki.org/xwiki/bin/view/Extension/ Background+color+for+a+ livetable
Now I want to change the display of the value of a specific column, for example to display an image or a button next to the value. This works only for the last column in the livetable. All other rows look strange.
Example:
The simplified code: ```
document.observe("xwiki:livetable:newrow", function(ev){ $$('.sTxtUser').each(function(element){
Debug your code and you'll see that:
* the xwiki:livetable:newrow event is fired for each row in the live table * $$('.sTxtUser') selects all the existing cells
So whenever a row is displayed you process not only that row but also the existing rows that have been displayed before..
var content = element.innerText; if(content === undefined){ content = element.textContent; } element.replace('<td class="sTxtUser link typetext" data-title="Username">"' + content + '"</td>') }); });
```
I have 3 documents for the application with the following values for
field
sTxtUser : testuser1 test12345 anotheruser1
Using the above extension renders the livetable cells like this: """anotheruser1""" ""test12345"" "testuser1"
If I change the sort order: """testuser1""" ""test12345"" "anotheruser1"
So only the last row shows the desired output.
What am I doing wrong?
Regards, Dennis
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On Thu, Nov 10, 2016 at 12:53 PM, D R <[email protected]> wrote:
Thanks Marius,
can you tell me how to avoid this and get the desired result or where I can find the information?
Regards, Dennis
2016-11-08 18:46 GMT+01:00 Marius Dumitru Florea < [email protected]>:
On Tue, Nov 8, 2016 at 4:38 PM, D R <[email protected]> wrote:
Hi,
Nobody here who can help me fix the Javascript Extension?
Regards, Dennis
2016-11-04 14:18 GMT+01:00 D R <[email protected]>:
Hi community,
I'm having a hard time getting a Javascript Extension for an AppWithinMinutes livetable to work.
I have several livetable "enhancements" in it like changing background color per field value which work properly.
As a reference I've used the example: http://snippets.xwiki.org/xwiki/bin/view/Extension/ Background+color+for+a+ livetable
Now I want to change the display of the value of a specific column, for example to display an image or a button next to the value. This works only for the last column in the livetable. All other rows look strange.
Example:
The simplified code: ```
document.observe("xwiki:livetable:newrow", function(ev){ $$('.sTxtUser').each(function(element){
See http://platform.xwiki.org/xwiki/bin/view/DevGuide/JavaScriptAPI#HLivetableev... . "*xwiki:livetable:newrow* (event.memo.row holds the new row)" Thus you can access the cell with: var cell = $(ev.memo.row).down('.sTxtUser');
Debug your code and you'll see that:
* the xwiki:livetable:newrow event is fired for each row in the live table * $$('.sTxtUser') selects all the existing cells
So whenever a row is displayed you process not only that row but also the existing rows that have been displayed before..
var content = element.innerText; if(content === undefined){ content = element.textContent; } element.replace('<td class="sTxtUser link typetext" data-title="Username">"' + content + '"</td>') }); });
```
I have 3 documents for the application with the following values for
field
sTxtUser : testuser1 test12345 anotheruser1
Using the above extension renders the livetable cells like this: """anotheruser1""" ""test12345"" "testuser1"
If I change the sort order: """testuser1""" ""test12345"" "anotheruser1"
So only the last row shows the desired output.
What am I doing wrong?
Regards, Dennis
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
D R -
Marius Dumitru Florea