alibaba / alist

Alibaba Group Unified List Solution.

Home Page:https://alist.wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

repeater 可否支持排序操作

thewei opened this issue · comments

有些场景可能需要用户对 repeater 进行排序操作,目前在文档没有看到这方面的功能。

原生的能力是不支持的,但是可以通过改变value来实现(后续也不打算支持,因为repeater和table之间有条界限,repeater处理大部分类表单的事项,如果太复杂就上升到table级别了)

const sortMethod = () => {
     const oldList = formCore.getItemValue('rp');
     const newList = oldList.sort(someSortMethod);
     formCore.setItemValue('rp', newList );
}

const trigger = <div onClick={sortMethod}>修改顺序</div>

<FormItem name="rp"><Repeater top={trigger} /></FormItem>