在材料设计数据表中没有显示默认列(iamisti/mdDataTable)

时间:2022-06-21 11:14:06

I am trying to populate the <mdt-column> inside of <mdt-header-row> dynamically with an array from controller. This piece of code doesn't seem to work properly:

我正在尝试用一个来自controller的数组动态填充 中的< mdb -column>。这段代码似乎不能正常工作:

hide-column-by-default="c.selector_hidden"

hide-column-by-default = " c.selector_hidden "

When loading the table default columns are not displayed. Some columns are set as default and are excluded from the "column-selector", so even after selecting all columns in the selector these columns are not displayed.

当加载表时,不显示默认列。一些列被设置为默认值,并被排除在“column-selector”中,因此,即使选择了选择器中的所有列,这些列也不会显示出来。

When i set ...columnSelector: false}... in table-card it shows me my columns, but the functions to select column is gone!?

当我……columnSelector:假}…在表卡中,它显示了我的列,但是选择列的函数已经消失了!

How can i fix this?

我该怎么解决这个问题呢?

This is the mdt-header-row:

这是mdt-header-row:

<mdt-header-row>
<mdt-column 
hide-column-by-default="c.selector_hidden" 
exclude-from-column-selector="c.selector_exclude" 
column-sort="c.sort" 
sortable-rows-default="c.sort_default" 
column-key="{{c.key}}"  
align-rule="{{c.align}}" 
column-definition="{{c.definition}}" 
ng-repeat="c in tableHeader"><span>{{c.name}}</span></mdt-column>

</mdt-header-row>

The Data is comming from this Array in controller:

数据来自controller中的这个数组:

$scope.tableHeader = [
        {
            name: 'Dessert (100g serving)',
            definition: '',
            align: 'left',
            sort: true,
            sort_default:false,
            hidden: false,
            selector_exclude:false,
            selector_hidden:false
        },...

I also created a fork for it: https://codepen.io/anon/pen/JJQyKN?editors=1111

我还为它创建了一个fork: https://codepen.io/anon/pen/jjqykn?

2 个解决方案

#1


1  

This piece of code doesn't seem to work properly:

这段代码似乎不能正常工作:

hide-column-by-default="c.selector_hidden"

hide-column-by-default = " c.selector_hidden "

That's because you don't have a selector_hidden property in any of the objects in your tableHeader array. It should look something like this:

这是因为在tableHeader数组中的任何对象中都没有selector_hidden属性。它应该是这样的:

$scope.tableHeader = [
        {
            name: 'Dessert (100g serving)',
            definition: '',
            align: 'left',
            sort: true,
            sort_default:false,
            hidden: false,
            selector_exclude:false,
            selector_hidden:true
        },...

#2


1  

Actually the issue is whit this directive it self. I had to modify the md-data-table.js file and change "isVisible" references column to true. I as well changed the isHidden property to "isVisable" because that is what is referenced by the md-data-table-templates.js file. I modified the code further to match our requirements and therefor cannot provide specific patches. However, unfortunately this project seems to be abandoned by the developer.

实际上问题是这个指令本身。我必须修改md-data表。将“isVisible”引用列更改为true。我还将isHidden属性更改为“isVisable”,因为md-data- tables模板引用的就是这个属性。js文件。我进一步修改了代码以符合我们的要求,因此不能提供特定的补丁。然而,不幸的是,这个项目似乎被开发人员抛弃了。

#1


1  

This piece of code doesn't seem to work properly:

这段代码似乎不能正常工作:

hide-column-by-default="c.selector_hidden"

hide-column-by-default = " c.selector_hidden "

That's because you don't have a selector_hidden property in any of the objects in your tableHeader array. It should look something like this:

这是因为在tableHeader数组中的任何对象中都没有selector_hidden属性。它应该是这样的:

$scope.tableHeader = [
        {
            name: 'Dessert (100g serving)',
            definition: '',
            align: 'left',
            sort: true,
            sort_default:false,
            hidden: false,
            selector_exclude:false,
            selector_hidden:true
        },...

#2


1  

Actually the issue is whit this directive it self. I had to modify the md-data-table.js file and change "isVisible" references column to true. I as well changed the isHidden property to "isVisable" because that is what is referenced by the md-data-table-templates.js file. I modified the code further to match our requirements and therefor cannot provide specific patches. However, unfortunately this project seems to be abandoned by the developer.

实际上问题是这个指令本身。我必须修改md-data表。将“isVisible”引用列更改为true。我还将isHidden属性更改为“isVisable”,因为md-data- tables模板引用的就是这个属性。js文件。我进一步修改了代码以符合我们的要求,因此不能提供特定的补丁。然而,不幸的是,这个项目似乎被开发人员抛弃了。