Skip to content

Listview html item modified by Javascript #572

Closed

Description

@itg-assistant

Mark Villela asked 2017-01-26 02:46:42 UTC

Hi

I have an item with a html

for example....

then...

I'm trying to modify this image dinammically... but..

When I try

Eval(alert(document.getElementById("img1").id);)

The img1 is not found.

I need to modify the image src for example:

document.getElementById("img1").src = "/icon2.png"

??

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2017-01-26 12:37:06 UTC

    Hi Mark,

    please try following the tips Luca has provided here:

    http://wisej.com/support/question/javascript-extender-code-and-element-id

    If it does not work, please provide us with a small sample.

    Thanks in advance !

    Best regards
    Frank

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2017-01-26 13:34:33 UTC

    Hi Mark,

    in addition to my previous reply, we also need to know the sequence of your calls, i.e.
    when does the code on the client needs to be executed.

    If you add the item and call your javascript code at the same time, the element is not present yet
    on the browser since the listview (and datagridview) uses a cached virtual data store ajax systemto retrieve the items/rows as you scroll.

    So please give us some more information to determine wether the item could still be outside the scrollable area
    or waiting for the servers pull request when your code is called.

    Thanks in advance,
    Frank

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Mark Villela answered 2017-01-26 19:52:56 UTC

    Can I modify the cached data?

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-01-27 19:16:26 UTC

    Yes you can but on the server side. The data is always coming from the server. The data reader on the client loads only the data pages that are needed for rendering and discards the rest. If you have 500 items (or rows) of data, the client only requests 20 or 30 (depending on the size of the scrollable area). As you scroll, the client asks for more and discards the blocks that are not needed according to memory needs.

    You can use Eval("document.getElementById('icon1').src='...'") and "icon1" is an element in a cell it works perfectly well but only if the cell is rendered and the html actually exists. On the server side, you can change it an any time, the server will issue a refresh command to the client and the client will reload the visible range.

    If you give a description of the requirement we can try to come up with another solution.

    HTH

    Best,
    Luca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions