Coder Social home page Coder Social logo

Comments (9)

jecovier avatar jecovier commented on July 25, 2024

It's a great idea!... the only thing I don't like is the ALL condition, because it's an arbitrary string and lost the ability to reach nested properties... maybe, return the last object you reach with the field value or if field it's undefined return the complete object

from vue-json-excel.

ljm42 avatar ljm42 commented on July 25, 2024

I don't think we lose access to nested properties, inside the callback you could just reference value.phone.mobile, right?

But I agree about "_ALL_". I like your idea of leaving the field undefined:

'Location': {
  callback: (value) => {
    return value.city + ", " + value.country;
  }
},

getValue() would just need a guard on the line that defines indexes:

getValue(key, item) {
  const field = typeof key === "object" ? key.field : key;
  let indexes = field ? field.split(".") : [];
  let value = this.defaultValue;

  if (!field)
	value = item;
  else if (indexes.length > 1)
	value = this.getValueFromNestedItem(item, indexes);
  else
	value = item[field];

  if (key.hasOwnProperty('callback'))
	value = this.getValueFromCallback(value, key.callback);

  return value;
},

from vue-json-excel.

jecovier avatar jecovier commented on July 25, 2024

@ljm42 thanks for the code, It's added with a little change (interpreter problems ¬¬) but its functional now... documentation was added to README file. Thanks!

from vue-json-excel.

ljm42 avatar ljm42 commented on July 25, 2024

Thanks! I like the way you explained it in the readme too

The mimetype has changed again though, can we change it back? Or make it an option somehow?

Also, in getValue(), I noticed that if you trigger this else statement:

 else
   value = item[field];

and don't have a callback, then parseValue() is never called on that value. Is that an issue?

from vue-json-excel.

jecovier avatar jecovier commented on July 25, 2024

@ljm42 🤦‍♂️ sorry, I've changed it in my local, it won't change again... yeah! I add the parseValue, thanks!

from vue-json-excel.

ljm42 avatar ljm42 commented on July 25, 2024

Sorry, the mimetype isn't quite right :)

This:
"vnd.ms-excel"
should be:
"application/vnd.ms-excel"

from vue-json-excel.

ljm42 avatar ljm42 commented on July 25, 2024

do you disagree?

from vue-json-excel.

jecovier avatar jecovier commented on July 25, 2024

🤦‍♂️ it's fixed now, thanks! 😃

from vue-json-excel.

ljm42 avatar ljm42 commented on July 25, 2024

perfect, thanks!

from vue-json-excel.

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.