Giter Club home page Giter Club logo

Comments (5)

renrizzolo avatar renrizzolo commented on August 24, 2024

Hi,
this isn't currently possible, do you have an example of why you'd need this over getting the object from your existing items with the key? It would be slight convenience but I don't think it's necessary.

from react-native-sectioned-multi-select.

iCodePup avatar iCodePup commented on August 24, 2024

Hi,

I fetch my data from remote API with following sample structure :

const items = [ { name: "Fruits", id: 0, children: [{ name: "Apple", id: 10, },{ name: "Strawberry", id: 17, },{ name: "Pineapple", id: 13, },{ name: "Banana", id: 14, },{ name: "Watermelon", id: 15, },{ name: "Kiwi fruit", id: 16, }] }, { name: "Gems", id: 1, children: [{ name: "Quartz", id: 20, },{ name: "Zircon", id: 21, },{ name: "Sapphire", id: 22, },{ name: "Topaz", id: 23, }] }, { name: "Plants", id: 2, children: [{ name: "Mother In Law\'s Tongue", id: 30, },{ name: "Yucca", id: 31, },{ name: "Monsteria", id: 32, },{ name: "Palm", id: 33, }] }, ]

Today if i select two elements, (Monsteria, Palm for example) i will have an selectedItems state array with two ID s

[32,33].

My need is to have an array with the full object with id 32 and 33 👍

    [{
        name: "Monsteria",
        id: 32,
      },{
        name: "Palm",
        id: 33,
      }]

I don't want to make an other request to API to get the full object to build a new array

Maybe i can filter on items and rebuild the object array but i can't find a good way to do this

from react-native-sectioned-multi-select.

renrizzolo avatar renrizzolo commented on August 24, 2024

Hi @iCodePup, if you have a look at the dev branch I've added the prop onSelectedItemObjectsChange. This is a function that returns the objects. (The main onSelectedItemsChange function still needs to be present).

The only caveat is that the parent items' child items will be contained in that object (as you get the object back exactly as it is) even though they aren't selected. Although I think it's clear that the top level objects are the selected ones.

Let me know if this works for you.

from react-native-sectioned-multi-select.

iCodePup avatar iCodePup commented on August 24, 2024

Hey ! Thanks 👍
It does the job but unfortunately onSelectedItemObjectsChange props seems to works for multiple select only .
It will be never call for single :(

from react-native-sectioned-multi-select.

renrizzolo avatar renrizzolo commented on August 24, 2024

@iCodePup thanks!

from react-native-sectioned-multi-select.

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.