ng-alain icon indicating copy to clipboard operation
ng-alain copied to clipboard

st: 提取st中与视图无关,仅与获取数据有关的行为,封装成一个新的数据源组件

Open zbrongyaozb opened this issue 3 years ago • 4 comments

What problem does this feature solve?

https://stackblitz.com/edit/ng-alain-setup-qgojxe?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fdata-source%2Fdata-source.component.html

通过st的data属性,可以方便快速的通过url来获取接口,并且支持分页。 但是视图渲染是能是表格。有些时候,希望自定义视图,但是又希望能用上st的data功能,来自动获取数据。

所以现在希望可以提供一个基础组件,它只负责提供一些数据相关的操作,比如包括导出重置删除等st原本就支持的功能。 在上面的例子中,我把st复制了一份,然后稍微改了改,模板里加了个分页,class里加了泛型。然后使用这个组件的时候,传入和st一样的属性,就可以拿到数据自行渲染了。

What does the proposed API look like?

希望如下: 1.新组件应当拥有所有st与视图渲染无关的方法与属性。 2.新组件可以拥有一些多余的属性和方法,这些方法可能是为了保障其它一些必要方法的正常运行。 3.最好st是继承自这个新组件的。 4.关于全局配置,可以独立一套也可和st共用一套,理论上影响不大。

另外这个功能不是太紧急,毕竟copy的也能用,但是还是希望可以用上官方支持的版本~

zbrongyaozb avatar Jun 29 '22 07:06 zbrongyaozb

Translation of this issue:

ST: Extracting the view that has nothing to do with the view, only the behavior related to obtaining data, encapsulates into a new data source component

What PROBLEM DOES This Feature Solve?

https://stackBitz.com/edit/ng- setup-qgojxe?file=src%2FApp%2FAPP.CONENENT.TS,src%2FApp.com source.comPonent.html

Through the DATA attribute of ST, you can easily and quickly obtain the interface through the URL and support paging. But view rendering is a table. Sometimes, I hope to customize the view, but I also hope to use the DATA function of ST to obtain data from mobility.

So now I hope to provide a basic component, which is only responsible for providing some data -related operations, such as the function that originally supports ST such as export reset and deletion. In the above example, I copied ST, and then changed it slightly. A paging was added to the template, and the classification was added to the class. Then when using this component, you can get the same attributes as ST, and you can get the data to render.

What does the proposed api look like?

Hope as follows:

  1. New components should have all ST methods and attributes that have nothing to do with view rendering.
  2. New components can have some excess attributes and methods. These methods may be to ensure the normal operation of other necessary methods.
  3. It is best to inherit this new component.
  4. Regarding the global configuration, it can be independent or ST, which can be shared with ST, which has little impact.

In addition, this function is not too urgent. After all, Copy can also be used, but I still hope that the official version can be used ~

alain-bot[bot] avatar Jun 29 '22 07:06 alain-bot[bot]

很简单 自定义一列就行了实例代码如下: Columns: STColumn[] = [{ title: '自定义', renderTitle: 'customTitle', render: 'custom' }];

wyq-L avatar Jul 23 '22 07:07 wyq-L

很简单 自定义一列就行了实例代码如下: Columns: STColumn[] = [{ title: '自定义', renderTitle: 'customTitle', render: 'custom' }];

不是要简单的自定义列,具体可以看看stackblitz里的demo里下方的卡片列表。

zbrongyaozb avatar Jul 25 '22 01:07 zbrongyaozb

之前我也提过一个类似的问题,后来自己选择通过单列自定义的方式来变相实现,关闭了那个问题。 但是这确实是个好问题,真的有这种需求。

xingkoo avatar Jul 27 '22 09:07 xingkoo