Element: [Bug Report] el-table-item property cannot support syntax like "array[index]" or "object[key]"

Created on 27 Jul 2017  ·  6Comments  ·  Source: ElemeFE/element

Element UI version

1.4.0

OS/Browsers version

Macos/Chrome

Vue version

2.3.4

Reproduction Link

https://jsfiddle.net/XGHeaven/b7w9Lj97/

Steps to reproduce

give "array[index]" or "object[key] wouldn't work correctly. but they are in form prop is correctly.

What is Expected?

table can find value by path like "array[index]" or "object[key]", even "array[index].key[index]", etc...

What is actually happening?

table can find value by path include "[", "]"

How to fix

I find the bug code in here
packages/table/src/table-column.js
Table property only use findValueByPath if path include . char.

And findValueByPath cannot support [] in util.js. But in form, getPropByPath can suuport [] syntax. I hope you can accord their behavior.

Most helpful comment

2.0 now supports this notation.

All 6 comments

You can use scoped template to implement custom value rendering

Of cause, I can do that as you said. But I think change the behaviour don't
difficult. I suggest you to keep them consistent.

On Aug 11, 2017 20:55, "Jiewei Qian" notifications@github.com wrote:

You can use scoped template to implement custom value rendering


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ElemeFE/element/issues/6112#issuecomment-321805000,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI3FzACwbGW8b-c1vT9bwOT_PdasE0VAks5sXE9cgaJpZM4OkulT
.

I bind the data is:

{
      tableData: {
        '2017-10-4': {
          'addSubscription': 1,
          'trySubscription': 2,
          'successSubscription': 3,
          'allUnsubscribe': 4,
          'non-firstUnsubscribe': 5,
          'firstErrorUnsubscribe': 7,
          'giveUp': 8,
          'secondSuccessSubscription': 9,
          'followUpUnsubscribe': 10,
          'subscribeSuccessRate': 11,
          'subscribeCompletionRate': 12
        },
        '2017-11-4': {
          'addSubscription': 1,
          'trySubscription': 2,
          'successSubscription': 3,
          'allUnsubscribe': 0,
          'non-firstUnsubscribe': 5,
          'firstErrorUnsubscribe': 7,
          'giveUp': 8,
          'secondSuccessSubscription': 0,
          'followUpUnsubscribe': 10,
          'subscribeSuccessRate': 0,
          'subscribeCompletionRate': 12
        }
      }
}

But can not be successfully bound.

The component throws an exceptio:
Uncaught TypeError: data.indexOf is not a function
and so on..

Is not it possible to bind to data like this?

Maybe contributor is so busy🙄. They don't have time to fix this.

On Oct 4, 2017 23:29, "星火燎原" notifications@github.com wrote:

I bind the data is:

{
tableData: {
'2017-10-4': {
'addSubscription': 1,
'trySubscription': 2,
'successSubscription': 3,
'allUnsubscribe': 4,
'non-firstUnsubscribe': 5,
'firstErrorUnsubscribe': 7,
'giveUp': 8,
'secondSuccessSubscription': 9,
'followUpUnsubscribe': 10,
'subscribeSuccessRate': 11,
'subscribeCompletionRate': 12
},
'2017-11-4': {
'addSubscription': 1,
'trySubscription': 2,
'successSubscription': 3,
'allUnsubscribe': 0,
'non-firstUnsubscribe': 5,
'firstErrorUnsubscribe': 7,
'giveUp': 8,
'secondSuccessSubscription': 0,
'followUpUnsubscribe': 10,
'subscribeSuccessRate': 0,
'subscribeCompletionRate': 12
}
}
}

But can not be successfully bound.

The component throws an exceptio:
[Vue warn]: Invalid prop: type check failed for prop "data". Expected
Array, got Object.
Uncaught TypeError: data.indexOf is not a function
and so on..

Is not it possible to bind to data like this?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ElemeFE/element/issues/6112#issuecomment-334194169,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI3FzK2oRb2sZalSlH3h78Wkr7y7Ck7Aks5so6RigaJpZM4OkulT
.

2.0 now supports this notation.

Thanks for the reminder, I will pay attention to the 2.0 document

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/ElemeFE/element","title":"ElemeFE/element","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/ElemeFE/element"}},"updates":{"snippets":[{"icon":"PERSON","message":"@Leopoldthecoder in #6112: 2.0 now supports this notation."}],"action":{"name":"View Issue","url":"https://github.com/ElemeFE/element/issues/6112#issuecomment-340960559"}}}

Was this page helpful?
0 / 5 - 0 ratings