Skip to content

Dynamic options list in Editable select column #1423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yakirg opened this issue Jun 26, 2017 · 14 comments
Closed

Dynamic options list in Editable select column #1423

yakirg opened this issue Jun 26, 2017 · 14 comments

Comments

@yakirg
Copy link

yakirg commented Jun 26, 2017

I have a problem where I have one column that is a type and another that is a refine on said type:

const posTypes = ["Any", "Noun", "Verb", "Adjective", "Adverb", "Cardinal number"];
const posRefineTypes = {
  "Any": [],
  "Noun": ["Any", "Single", "Plural", "Proper noun single", "Proper noun plural"],
  "Verb": ["Any", "Base form", "Past tense", "gerund or present participle", "past participle", "non-3rd person singular present", "3rd person singular present"],
  "Adjective": ["Any", "Comparative", "Superlative"],
  "Adverb": ["Any", "Comparative", "Superlative"],
  "Cardinal number": []
};
...

           <TableHeaderColumn
                dataField='Pos' editable={ {type: 'select', options: {values: posTypes}} }
                width={"120px"}>
              Pos
            </TableHeaderColumn>

            <TableHeaderColumn
                dataField='Refine'
                editable={  {type: 'select', options: {values: posRefineTypes[Pos]}} }
                width={"120px"}>
              Refine
            </TableHeaderColumn>   

I need the options in the sub type to match the type, but it has to be a constant.

Is there a way to get it done?

@AllenFang
Copy link
Owner

@yakirg, it's impossible now but I have few question

options: {values: posRefineTypes[Pos]}} }

what's the Pos?? which depend on previous column value? thanks

@yakirg
Copy link
Author

yakirg commented Jun 30, 2017

Pos is one column select value (stands for Parts Of Speech)
Refine is the next column, which has options that relate to the value selected in Pos.

Hope this clears a bit ...

@AllenFang
Copy link
Owner

@yakirg, I probably know your requirement, I'll consider to add this feature by a callback function, you can decide what options list you want depend on row data, that's what I think but I need to check code and no schedule promise here, sorry for that due to busy recently. thanks

@yakirg
Copy link
Author

yakirg commented Jul 4, 2017

@allen, a callback will be great! Thanks.

yakirg pushed a commit to yakirg/react-bootstrap-table that referenced this issue Jul 7, 2017
Still missing support for insert dialog.
@yakirg
Copy link
Author

yakirg commented Jul 7, 2017

Created a PR with a suggested fix.
It is still problematic on the insert new dialog part, because the row doesn't exist, but it's usable as is.

@AllenFang
Copy link
Owner

@yakirg, nice !! I will check this out. 👍

@AllenFang
Copy link
Owner

Fixed on v4.0.0-beta.8

trongthanh added a commit to goalifyplus/react-bootstrap-table that referenced this issue Jul 18, 2017
* commit 'c7ab34cabb40a66fe237a12413cb31798cdb4ff1': (32 commits)
  v4.0.0-beta.8
  prod
  example for AllenFang#1478
  refine for setting attributes on editor
  example for AllenFang#1423
  fix bug for wrong select options
  add ref and event handling
  simplify combining attrs
  allow setting attrs on editable cells
  v4.0.0-beta.7
  prod
  Dynamic options list in Editable select column AllenFang#1423 Still missing support for insert dialog.
  v4.0.0-beta.6
  prod
  remove redundant state
  issue-1130: added show to make size dropdown compatible with bootstrap4
  v4.0.0-beta.5
  prod
  replace React.PropTypes with `prop-types`
  replace PropTypes with `prop-types` library to remove warnings
  ...
@AllenFang
Copy link
Owner

v4.0.0 release

@shanben7
Copy link

shanben7 commented Dec 7, 2017

Hi, I believe I am still having the problem @yakirg mentioned where the the "row" is undefined in the insert dialog, and so I cannot choose my values this way for the insert dialog. Is there a fix for this? I am using version react-bootstrap-table v4.0.5.

@yakirg
Copy link
Author

yakirg commented Dec 8, 2017 via email

@nkarmak
Copy link

nkarmak commented Nov 19, 2018

I am not able to get this going. I am trying to filter the drop down menu options based on the value of one of the other columns, but the column it depends on is not editable.

    const dropDownOptions = {
      type: 'select',
      options: { values: this.state.selected_values['Product_Name'] }
    };

this.state.selected_values is an object which has the same structure as posRefineTypes defined above, with the key being values of 'Product_Name' and the values being array of facilities.

  <TableHeaderColumn width='35%' dataField='Product_Name' isKey dataAlign="center" dataSort={ true } >Product Name</TableHeaderColumn>
  <TableHeaderColumn width='35%' dataField='facility_name'  dataAlign="center" editable={dropDownOptions} dataSort={ true }>Fixed Facillity Name</TableHeaderColumn>
Is this correct?

@ashish00076
Copy link

@AllenFang @yakirg was the insert dialog issue fixed here ?

Please respond, critical situation.

Thanks & Regards,
Ashish Deshpande

@yakirg
Copy link
Author

yakirg commented May 16, 2019

My last comment still stands. The insert was never fixed (to my knowledge) but it's not too critical for me, my users create first and edit later.

@NikhithaPeesari
Copy link

NikhithaPeesari commented Nov 7, 2019

I am not able to get this going. I am trying to filter the drop down menu options based on the value of one of the other columns, but the column it depends on is not editable.

    const dropDownOptions = {
      type: 'select',
      options: { values: this.state.selected_values['Product_Name'] }
    };

this.state.selected_values is an object which has the same structure as posRefineTypes defined above, with the key being values of 'Product_Name' and the values being array of facilities.

  <TableHeaderColumn width='35%' dataField='Product_Name' isKey dataAlign="center" dataSort={ true } >Product Name</TableHeaderColumn>
  <TableHeaderColumn width='35%' dataField='facility_name'  dataAlign="center" editable={dropDownOptions} dataSort={ true }>Fixed Facillity Name</TableHeaderColumn>
Is this correct?

i am facing a similar issue. Any suggestions on how to resolve it?Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants