Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6877951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:39:48+00:00 2026-05-27T04:39:48+00:00

Here is a code excerpt from a dhtmlxgrid sample file: <p> You are allowed

  • 0

Here is a code excerpt from a dhtmlxgrid sample file:

   <p> You are allowed to clear data and structure of grid and then load new data from XML file.</p>

    <a href="#" onclick="savegrid();">Save Grid</a>
   <div id="gridbox" style="width:600px; height:270px; background-color:white;"></div>
    <a href='#alfa' onClick="ser()">Reload grid with another structure</a>
<br>
<script>
    mygrid = new dhtmlXGridObject('gridbox');
    mygrid.setImagePath("../../codebase/imgs/");
    mygrid.loadXML("../common/grid500.xml");


    function ser(){
        mygrid.clearAll(true);
        mygrid.loadXML("../common/gridH3.xml");
    }

    function savegrid(){
        // want to save the grid here   
    }
</script>

If I edit data in the grid. I’d like to be able to save it to file. How do I do that? This isn’t done automatically.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:39:49+00:00Added an answer on May 27, 2026 at 4:39 am

    It is possible to get a csv or an XML of the dhtmlxgrid current data and have scripts to save the updates to a database or an xml file. The dhtmlxgrid method to load a csv into the grid is .loadCSVString(). The method to load an xml file is .loadXML(). The method to create a csv string with the current grid content is .serializeToCSV(). The method to create an xml with the current grid content is .serialize().

    Here is a sample use of the grid. The data to be shown and edited in the grid is stored in an XML file. The updates/edits made in the grid must also be stored in that XML file. Since my XML file has a different definition than the XML that dhdmlxgrid uses, I extract the data from the XML as a csv string, load the string into the grid, then extract the updates as a csv string to save back to the XML. The code to do that is simpler than switching between the two xml formats.

    HTML

    One div is defined to be the grid element. Save and Cancel buttons are also defined.

    <div id="links_grid" style="width: 100%; height: 189px; margin-bottom: 4px; border: 1px solid silver;">
    </div>
    <button onclick="save_node_xml(\''+card_id+'\')">Save</button>&nbsp; 
    <button onclick="cancel_node_grid(\''+card_id+'\')">Cancel</button>
    

    Grid Initialization

    In this javascxript the grid object is created and filled with data.

            // Retrieve grid data from XML as CSV data (dhtmlx has other ways to link to data sources)
    
            grid_csv = $.ajax({
                url: "get_node_urls.php",
                type: "POST",
                data: { nodeid: card_id },
                cache: false,
                async: false,
                success: function (response) {
                    if (response != '') 
                    {
                        /* alert(response); */
                    }
                }
           }).responseText;
    
           // Create grid and load data
    
            card_links_grid = new dhtmlXGridObject('links_grid'); 
            card_links_grid.setImagePath("dhtmlxGrid_dnld/codebase/imgs/"); 
            card_links_grid.setHeader("ID,Title,URL"); 
            card_links_grid.setInitWidths("50,120,190"); 
            card_links_grid.setColAlign("right,left,left"); 
            card_links_grid.setColTypes("ed,ed,ed");
            card_links_grid.setColSorting("str,str,str"); 
            card_links_grid.enableDragAndDrop(true);
            card_links_grid.init(); 
            card_links_grid.setColumnHidden(0,true); 
            card_links_grid.setSkin("dhx_skyblue");
            card_links_grid.bF(false); 
            card_links_grid.loadCSVString(grid_csv); // Load csv generated from XML data
            // Fix formatting, apply here styles to override what is hardcoded in the grid code
            $('table.hdr td',$('#links_grid')).css('padding','0');
            $('table.hdr td',$('#links_grid')).css('height','16');
            $('table.hdr td div.hdrcell',$('#links_grid')).css('margin','0');
            $('table.hdr td div.hdrcell',$('#links_grid')).css('height','16');
    

    Save Data

    In this script the grid content are retrieved and saved to XML.

        // Get grid data as CSV
        grid_csv = card_links_grid.serializeToCSV();
    
        // Make array from CSV
        var links_array = CSVToArray(grid_csv); // special function to make array from csv
    
        // Send data to XML
        for (var i=0; i<links_array.length; i++) {
            var link = links_array[i];
            var link_ix = link[0];
            var link_id = link[1];
            var link_title = link[2];
            var link_url = link[3];
    
            // Add updated links to XML
            $.ajax({
                url: "add_url.php",
                type: "POST",
                data: { nodeid: card_id, linkid: link_id, linktitle: link_title, linkurl: link_url },
                cache: false,
                async: false,
                success: function (response) {
                    if (response != '') 
                    {
                        // alert(response);             
                   }
                }
            }); 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a code excerpt from AspComet project that works with Autofac. public MessageBus(IClientRepository
What did I do wrong? Here is an excerpt from my code: public void
Consider an excerpt from code that can be found here : namespace WinSearchFile {
The following is an excerpt from a code sample in K&R's The C Programming
I am currently reading the PostgreSql code. Here is an excerpt from the buffer
Here is code from MSDN . I don't understand why the work isn't just
Here's the relevant excerpt from the documentation of the ref function: The value returned
Here is an excerpt from Mixed Effects Models in S and S-Plus page 238
Here is the code excerpt. std::map<double, double> temp; temp[0] = .1; cout << temp[1]
The following is an excerpt from some code that I'm experimenting with: has buffer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.