element icon indicating copy to clipboard operation
element copied to clipboard

[Feature Request] Can I set default selected value for Cascader?

Open ghost opened this issue 3 years ago • 12 comments

Existing Component

Yes

Component Name

Cascader

Description

Can I set default selected value for Cascader?

ghost avatar Dec 17 '21 03:12 ghost

Please read the official documentation carefully。You can use v-model to bind default value.

OGweixin007 avatar Dec 21 '21 06:12 OGweixin007

Please read the official documentation carefully。You can use v-model to bind default value.

I mean can I set one value 'selected' in the Cascader so I don't need to select it every time.

ghost avatar Dec 21 '21 08:12 ghost

Yeah,that is what i mean.  You don`t setlect any value in the Cascader.  v-model='option'   The type of this 'option' is a list , you  can set some values in it, and then display them in the Cascader as a default value. 

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 下午4:30 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557)

Please read the official documentation carefully。You can use v-model to bind default value.

I mean can I set one value 'selected' in the Cascader so I don't need to select it every time.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

OGweixin007 avatar Dec 21 '21 09:12 OGweixin007

There is a mistake, it can be any type.  v-model='option'  The value of the 'option' must be included in the cascader-list.

------------------ 原始邮件 ------------------ 发件人: "ElemeFE/element" @.>; 发送时间: 2021年12月21日(星期二) 下午4:30 @.>; @.@.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557)

Please read the official documentation carefully。You can use v-model to bind default value.

I mean can I set one value 'selected' in the Cascader so I don't need to select it every time.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

OGweixin007 avatar Dec 21 '21 09:12 OGweixin007

image I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use image but how should we do it in Cascader?

ghost avatar Dec 21 '21 14:12 ghost

emm..just like what I said.  v-model='value' . The value is a list. The structure of the value needs to correspond to the tree structure of the 'option' list.

my code..

value: ['a'],       // value: ['b', 'b1'],       // value: ['c', 'c1', 'c11'],       options: [         {           value: 'a',           label: 'A'         },         {           value: 'b',           label: 'B',           children: [             {               value: 'b1',               label: 'B-1'             }           ]         },         {           value: 'c',           label: 'C',           children: [             {               value: 'c1',               label: 'C-1',               children: [                 {                   value: 'c11',                   label: 'C-1-1'                 }               ]             }           ]         }       ]

I tried it out using an example from Element's website, it worked! You dont`t need to search 'value' of options and click to make it selected.

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 晚上10:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557)

I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use 'fiscal_year_week ', but how should we do it in Cascader? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

OGweixin007 avatar Dec 22 '21 01:12 OGweixin007

emm..just like what I said.  v-model='value' . The value is a list. The structure of the value needs to correspond to the tree structure of the 'option' list. my code.. <div class="block">       <span class="demonstration">Factor1: </span>       <el-cascader         v-model="value"         clearable         :options="options"         @change="handleChange"       />     </div> value: ['a'],       // value: ['b', 'b1'],       // value: ['c', 'c1', 'c11'],       options: [         {           value: 'a',           label: 'A'         },         {           value: 'b',           label: 'B',           children: [             {               value: 'b1',               label: 'B-1'             }           ]         },         {           value: 'c',           label: 'C',           children: [             {               value: 'c1',               label: 'C-1',               children: [                 {                   value: 'c11',                   label: 'C-1-1'                 }               ]             }           ]         }       ] I tried it out using an example from Element's website, it worked! You dont`t need to search 'value' of options and click to make it selected. ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 晚上10:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use 'fiscal_year_week ', but how should we do it in Cascader? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

Got it, thank you so much

ghost avatar Jan 05 '22 03:01 ghost

You are welcome! Nice to help you.By the way ,where are you come form?

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年1月5日(星期三) 中午11:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557)

emm..just like what I said.  v-model='value' . The value is a list. The structure of the value needs to correspond to the tree structure of the 'option' list. my code.. <div class="block">       <span class="demonstration">Factor1: </span>       <el-cascader         v-model="value"         clearable         :options="options"         @change="handleChange"       />     </div> value: ['a'],       // value: ['b', 'b1'],       // value: ['c', 'c1', 'c11'],       options: [         {           value: 'a',           label: 'A'         },         {           value: 'b',           label: 'B',           children: [             {               value: 'b1',               label: 'B-1'             }           ]         },         {           value: 'c',           label: 'C',           children: [             {               value: 'c1',               label: 'C-1',               children: [                 {                   value: 'c11',                   label: 'C-1-1'                 }               ]             }           ]         }       ] I tried it out using an example from Element's website, it worked! You dont`t need to search 'value' of options and click to make it selected. … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 晚上10:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use 'fiscal_year_week ', but how should we do it in Cascader? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

Got it, thank you so much

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

OGweixin007 avatar Jan 06 '22 06:01 OGweixin007

You are welcome! Nice to help you.By the way ,where are you come form? ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年1月5日(星期三) 中午11:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) emm..just like what I said.  v-model='value' . The value is a list. The structure of the value needs to correspond to the tree structure of the 'option' list. my code.. <div class="block">       <span class="demonstration">Factor1: </span>       <el-cascader         v-model="value"         clearable         :options="options"         @change="handleChange"       />     </div> value: ['a'],       // value: ['b', 'b1'],       // value: ['c', 'c1', 'c11'],       options: [         {           value: 'a',           label: 'A'         },         {           value: 'b',           label: 'B',           children: [             {               value: 'b1',               label: 'B-1'             }           ]         },         {           value: 'c',           label: 'C',           children: [             {               value: 'c1',               label: 'C-1',               children: [                 {                   value: 'c11',                   label: 'C-1-1'                 }               ]             }           ]         }       ] I tried it out using an example from Element's website, it worked! You dont`t need to search 'value' of options and click to make it selected. … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 晚上10:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use 'fiscal_year_week ', but how should we do it in Cascader? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.> Got it, thank you so much — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.>

I'm from China.

ghost avatar Jan 06 '22 06:01 ghost

 老铁,你早说啊。

------------------ 原始邮件 ------------------ 发件人: "ElemeFE/element" @.>; 发送时间: 2022年1月6日(星期四) 下午2:58 @.>; @.@.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557)

You are welcome! Nice to help you.By the way ,where are you come form? … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年1月5日(星期三) 中午11:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) emm..just like what I said.  v-model='value' . The value is a list. The structure of the value needs to correspond to the tree structure of the 'option' list. my code.. <div class="block">       <span class="demonstration">Factor1: </span>       <el-cascader         v-model="value"         clearable         :options="options"         @change="handleChange"       />     </div> value: ['a'],       // value: ['b', 'b1'],       // value: ['c', 'c1', 'c11'],       options: [         {           value: 'a',           label: 'A'         },         {           value: 'b',           label: 'B',           children: [             {               value: 'b1',               label: 'B-1'             }           ]         },         {           value: 'c',           label: 'C',           children: [             {               value: 'c1',               label: 'C-1',               children: [                 {                   value: 'c11',                   label: 'C-1-1'                 }               ]             }           ]         }       ] I tried it out using an example from Element's website, it worked! You dont`t need to search 'value' of options and click to make it selected. … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 晚上10:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use 'fiscal_year_week ', but how should we do it in Cascader? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.> Got it, thank you so much — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.>

I'm from China.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

OGweixin007 avatar Jan 06 '22 07:01 OGweixin007

 老铁,你早说啊。 ------------------ 原始邮件 ------------------ 发件人: "ElemeFE/element" @.>; 发送时间: 2022年1月6日(星期四) 下午2:58 @.>; @.@.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) You are welcome! Nice to help you.By the way ,where are you come form? … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年1月5日(星期三) 中午11:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) emm..just like what I said.  v-model='value' . The value is a list. The structure of the value needs to correspond to the tree structure of the 'option' list. my code.. <div class="block">       <span class="demonstration">Factor1: </span>       <el-cascader         v-model="value"         clearable         :options="options"         @change="handleChange"       />     </div> value: ['a'],       // value: ['b', 'b1'],       // value: ['c', 'c1', 'c11'],       options: [         {           value: 'a',           label: 'A'         },         {           value: 'b',           label: 'B',           children: [             {               value: 'b1',               label: 'B-1'             }           ]         },         {           value: 'c',           label: 'C',           children: [             {               value: 'c1',               label: 'C-1',               children: [                 {                   value: 'c11',                   label: 'C-1-1'                 }               ]             }           ]         }       ] I tried it out using an example from Element's website, it worked! You dont`t need to search 'value' of options and click to make it selected. … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月21日(星期二) 晚上10:35 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ElemeFE/element] [Feature Request] Can I set default selected value for Cascader? (Issue #21557) I mean, how can I set one of the values in the 'option' list selected? Like shown in the screenshot, I need to search 'fiscal_year_week' and click to make it selected, how should it set to be selected by default that I don't need to click it manually. If we are using normal html, just use 'fiscal_year_week ', but how should we do it in Cascader? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.> Got it, thank you so much — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.> I'm from China. — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

哈哈。

ghost avatar Jan 06 '22 07:01 ghost

笑死我了

WDJ-webDeveloper avatar Feb 28 '24 08:02 WDJ-webDeveloper