【问题标题】:How to have editable fields through liferay search container?如何通过 liferay 搜索容器拥有可编辑的字段?
【发布时间】:2014-05-05 13:50:27
【问题描述】:

我是 Liferay 开发的新手。

我在使用 liferay 搜索容器显示 liferay 网格方面做得很好。

但现在的要求是网格中的某些字段应该有供用户修改的规定。

是否可以通过 liferay 搜索容器或者我需要遵循任何其他方法来实现可编辑的 liferay 网格?

【问题讨论】:

  • 您可以将字段显示为输入文本而不是标签,并且使用一些ajax机制可以保存行数据
  • 我正在使用此标签“"。要将字段显示为输入文本,我尝试过 但它不起作用。您能详细说明一下吗?

标签: liferay portlet liferay-6


【解决方案1】:

您可以使用<liferay-ui:search-container-column-jsp标签或直接在<liferay-ui:search-container-column-text标签内使用<aui-input />

示例(我在代码示例中包含了代码 cmets 以供您理解):

<liferay-ui:search-container
    emptyResultsMessage="no-assets-selected"
    iteratorURL="<%= configurationRenderURL %>"
    total="<%= assetEntries.size() %>"
>
    <liferay-ui:search-container-results
        results="<%= assetEntries.subList(searchContainer.getStart(), searchContainer.getResultEnd()) %>"
    />

    <liferay-ui:search-container-row
        className="com.liferay.portlet.asset.model.AssetEntry"
        escapedModel="<%= true %>"
        keyProperty="entryId"
        modelVar="assetEntry"
    >

        <aui:form action="doesThisWork?">

            <%-- this is the normal way --%>
            <liferay-ui:search-container-column-text
                name="type"
                value="<%= assetRendererFactory.getTypeName(locale, false) %>"
            />

            <liferay-ui:search-container-column-date
                name="modified-date"
                value="<%= assetEntry.getModifiedDate() %>"
            />

            <%--
                this is the JSP way 
                You can include anything in the JSP like <input /> fields, textarea, select drop-down etc.
            --%>
            <liferay-ui:search-container-column-jsp
                align="right"
                path="/html/portlet/asset_publisher/asset_selection_action.jsp"
            />

            <%--
                Here is including <input /> field inside the column text field.
                Notice I am not using the "value" attribute of this tag, instead I am
                writing HTML inside the body of this tag.
            --%>
            <liferay-ui:search-container-column-text
                name="type"
            >
                <aui:input type="text" name="enterSomething" value="I can enter input here" />
                <aui:input type="text" name="enterSomething" value="<%=assetEntry.getTitle %>" />
                <aui:input type="hidden" name="enterSomething" value="this is a hidden field of the form" />
            </liferay-ui:search-container-column-text>

        </aui:form>
    </liferay-ui:search-container-row>

    <liferay-ui:search-iterator paginate="<%= total > SearchContainer.DEFAULT_DELTA %>" />
</liferay-ui:search-container>

在上面的示例中,每一行都有一个&lt;form&gt;,因此您可以在每一行的末尾有一个提交按钮来提交该行的数据。

但你也可以通过其他方式做到这一点:

  1. 您可以在 Search-container 标签之外写上&lt;form&gt;,这样您就只有一个表单,并且可以将所有行数据一起提交
  2. 否则,您可以在页面下方的某处使用&lt;form&gt;,并通过 javascript 填充表单中的值,然后提交。
  3. 否则您可以使用 ajax 和其他东西来完成此操作。或多种方法的组合。

这件事留给你自己解决。

免责声明:我没有测试过这段代码。但据我了解,这应该可行。 :-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-31
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    相关资源
    最近更新 更多