Giter Site home page Giter Site logo

Comments (6)

ryanlanciaux avatar ryanlanciaux commented on May 18, 2024

Hi there and thanks for posting this question! I appreciate all the detail you put into describing the issues you are running into.

It seems that the external results is one area we need to document at bit better. In the near future here we'll write a much more thorough example of using the external results and hopefully clean up some of the issues that are commonly encountered with that part of Griddle. I hope to have that online by this weekend.

Thanks again for being a first time Github poster on our repository :)

from griddle.

0xdabbad00 avatar 0xdabbad00 commented on May 18, 2024

For anyone else that is coming from jQuery datatables, I make an ajax call using the https://github.com/ded/reqwest library (so I don't have jquery at all in my project). This works very similarly to jQuery's $.ajax({ by using Reqwest({ instead.

Then I need to modify some things with the results returned, so I make a temporary results array as follows:

success: function (resp) {
  var results = [];
  for (var i=0; i<resp.iTotalDisplayRecords; i++)
  {
    results[i] = {
      "Path" : resp.aaData[i]["FilePath"],
      "Last Seen": resp.aaData[i]["LastSeen"],
      "First Seen": resp.aaData[i]["FirstSeen"],
      "Count": resp.aaData[i]["NumSystems"]
    };
  }

  callback({
    results: results,
    totalResults: resp.iTotalRecords
  });
},

from griddle.

sam3k avatar sam3k commented on May 18, 2024

What about when you do an ajax call on form submit? This is the only workaround I've found:

loadItUp: function(filterString, sortColumn, sortAscending, page, pageSize, callback, e) {
    if(e) {
    $.ajax({
      url: 'musings.json',
      dataType: 'json',
      success: function(data) {
        callback({
          results: data,
          totalResults: data.length
        });
      }.bind(this),
      error: function(xhr, status,err) {
        console.error(xhr, status, err.toString());
      }.bind(this)
    });    

    } else {
       callback({
          results: data,
          totalResults: data.length
        });
    }
  },  
  handleSubmit: function(e) {
      e.preventDefault();
      this.loadItUp(null, null, null, null, null, function(){}, e);
      return;
  },
  render: function() {
    return (
        <form onSubmit={this.handleSubmit}>
            <Griddle getExternalResults={this.loadItUp} tableClassName="table" />
        </form>
    )
  }  

It works but it kinda defeats the purpose of using ReactJS state/props plus it feels wrong. =/

from griddle.

ryanlanciaux avatar ryanlanciaux commented on May 18, 2024

Hey @sam3k -- thanks for posting! I agree -- we are currently refactoring the external results to be more react-y. It's working on our manual examples but I'm trying to get more tests around the functionality and shim in the callback (so we don't break the grid for anyone using the callback method in the immediate future) before pushing it to the released version.

This functionality is available on this branch and once more of the tests are done it will be in npm as a pre-release version.

from griddle.

sam3k avatar sam3k commented on May 18, 2024

Using that branch (and switching to "results" instead of "getExternalResults" works perfect. Thanks @ryanlanciaux

from griddle.

ryanlanciaux avatar ryanlanciaux commented on May 18, 2024

I'm closing this out as the ver0.2.0 release should have made this sort of thing a bit easier. The external data documentation contains some better example than the original docs. Please feel free to ping me if this is still giving you trouble! 👍

from griddle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.