jQWidgets Forums

jQuery UI Widgets Forums Grid Clearing jqxWindow

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  njenga 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Clearing jqxWindow #135943

    njenga
    Participant

    Hi! How do I clear the contents of a jqxWindow that is being re-used?? I have a grid_main with an onClick event that loads a window with different content (jqxGrids) depending on which cell is clicked in grid_main. Currently the window pops up with all the grids as I click on different cells. I’d like to clear the previous content (a jqxGrid) and load the relevant content.

    Clearing jqxWindow #135945

    admin
    Keymaster

    Hi njenga, Always destroy the existing jqxGrid if it was initialized previously, otherwise memory leaks or rendering issues can occur. You can keep a simple #windowContent container and append dynamic grid placeholders like #newGrid inside it each time. $("#grid_main").on('cellclick', function (event) { // Clear previous content $("#windowContent").jqxGrid('destroy'); // If a jqxGrid exists, destroy it $("#windowContent").empty(); // Remove all HTML content // Optionally: recreate a placeholder div for the new grid $("#windowContent").append(''); // Create a new jqxGrid based on the clicked cell $("#newGrid").jqxGrid({ width: 600, source: getNewDataAdapter(event), // Your custom function columns: [ { text: 'Name', datafield: 'name' }, { text: 'Age', datafield: 'age' } ] }); // Open the jqxWindow $("#myWindow").jqxWindow('open'); }); Regards, Peter jQWidgets Team https://www.jqwidgets.com/

    Clearing jqxWindow #135947

    njenga
    Participant

    Perfect! Thanks Peter!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.