We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    example? Which class depending on which value in which column?
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 36551
      • 416 Posts
      Let's say I have this table:

      <tr>
      <td>Product Name</td>
      <td>Product Number</td>
      <td>Product Characteristic 1</td>
      <td>Product Characteristic 2</td>
      <td>Product Category</td>
      <td>Manufacturer</td>
      </tr>

      I will want to be able to sort or filter the table rows based on one or more classes in the row. I don't yet know which but it will require more than one class for a given row.

      For example this row might become:

      <tr class="Product-category Manufacturer">
      <td>Product Name</td>
      <td>Product Number</td>
      <td>Product Characteristic 1</td>
      <td>Product Characteristic 2</td>
      <td>Product Category</td>
      <td>Manufacturer</td>
      </tr>

        • 49054
        • 2 Posts
        Quote from: Bruno17 at Sep 04, 2013, 12:38 AM
        with some little tricks it should be possible to have a import csv - button above the MIGX-grid, which could open a modal-window with a textarea, where you can paste the csv-code and import it as json for MIGX or have an upload-button for uploading a csv-file and importing it at the same time into the MIGX-grid.

        What are the little tricks to add a button above migx-grid to add csv data? Does it require re-writing migx? I have a csv file I would like upload that has 50+ headings and rows. It would be nice if you could help so I don't have to add them one at a time.
          • 3749
          • 24,544 Posts
          Terry,

          If the field value options are a small set, you can name your classes after the values and use double placeholders in the Tpl chunk:


          <td class="[[+product.characteristic.1]]">[[+product.characteristic.1]]</td>
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 49054
            • 2 Posts
            Quote from: mintnl at Sep 18, 2015, 11:43 AM
            Hi Ben,

            No, not yet...
            Solved in another way i believe...

            Still interested though in how to create such an import button for CSV 2 MIGX.

            How did you solve?
              • 4172
              • 5,888 Posts
              I think the simplest solution for now, would be to create a textarea-TV where you can put the CSV-Data and a plugin, which runs at OnDocFormSave to import the CSV-Data from textarea into the MIGX-TV, if the textarea is not empty and empty the textarea-TV after import.

              There is also an option in the MIGX-Configurator-CMP where you can select an action-button for import/export from/to json. Maybe this could work, if you can convert your CSV to json-data.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 4172
                • 5,888 Posts
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 36818
                  • 119 Posts
                  [UPDATE]
                  Found a solution. Just commented out:
                   $row['_fields'] = '';
                  around line 84.
                  Now there is no additional
                  <td></td>
                  .
                  [/UPDATE]


                  Short question to the wonderful snippet
                  [[getCsvFileItems]]
                  from Bruno (see https://forums.modx.com/thread/86471/how-to-import-excel-data-and-how-to-show-them-on-front-end-page?page=2#dis-post-476682)


                  CSV:
                  "Name","Adresse","PLZ","Ort"
                  "Keith West","West Rd.","36501","Fontecchio"


                  Result:
                  <table>
                  <thead>
                  <tr>
                  <th>Name</th>
                  <th>Adresse</th>
                  <th>PLZ</th>
                  <th>Ort</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                  <td>Keith West</td>
                  <td>West Rd.</td>
                  <td>36501</td>
                  <td>Fontecchio</td>
                  <td></td>
                  </tr>
                  </tbody>
                  </table>


                  there is always an additional <td></td> at the end form the second line. The csv-file has 4 columns but shows 5 from the second line on. Why could that be? [ed. note: achterbahn last edited this post 7 years, 10 months ago.]
                    • 40385
                    • 75 Posts
                    Quote from: Bruno17 at Dec 10, 2015, 07:26 AM
                    Import CSV - Button is there, now
                    https://github.com/Bruno17/MIGX/commit/0c882a55050687851f7128e3828637abefa539b4

                    I am still stuck here. I activated/checked the importcsvmigx actionbutton. The button is in my grid, I can upload and select a csv file, but nothing happens, except for this js error:

                    ext-all.js:21 Uncaught TypeError: Cannot read property 'length' of undefined


                    What am I missing here?

                    Thanks in advance! [ed. note: paul_kemp last edited this post 7 years, 8 months ago.]
                      • 4172
                      • 5,888 Posts
                      is it for a MIGX-TV or is it for a custom-table?
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!