0

我正在使用struts2hibernate做我的项目,我正在使用jqgrid进行数据显示。现在我想在 editGrid 窗口上为 id 字段设置只读属性。但不适用于添加窗口。我的示例代码

<sjg:grid id="gridtable"
    caption="Customer List"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="customerList"
    rowNum="10"
    autowidth="true"
    editurl="%{editurl}"
    editinline="false"
    navigator="true"
    navigatorAdd="true"
    navigatorAddOptions="
        {
            viewPagerButtons:false,
            recreateForm:true,
            checkOnUpdate:true,
            closeAfterAdd:true
        }"
    navigatorDelete="true"
    navigatorEdit="true"
    navigatorRefresh="true"
    navigatorSearch="true"
    navigatorEditOptions="
        {
            viewPagerButtons:false,
            recreateForm:true,
            checkOnUpdate:true,
            closeAfterEdit:true
        }"
    navigatorDeleteOptions="{ checkOnUpdate:true}"
    navigatorViewOptions="
        {
            viewPagerButtons:false,
            recreateForm: true,
            checkOnUpdate: true
        }"
    navigatorSearchOptions="{sopt:['eq','ne','lt','gt','in','ni','cn','nc']}"
    navigatorView="true"
    rownumbers="true"
    rowList="10,20,30"
    viewrecords="true"
>
<sjg:gridColumn
    name="id"
    align="left"
    key="true"
    index="id"
    title="Customer id"
    sortable="false"
    editable="true"
    editrules="{
        number: true,
        required: true
    }"
    edittype="text" />
<sjg:gridColumn
    name="custName"
    align="left"
    index="custName"
    title="Customer Name"
    sortable="false"
    editable="true"
    edittype="text" />
    ......
</sjg:grid>

我可以在navigatorEditOption中调用beforeShowForm和函数吗?afterShowForm

4

1 回答 1

0

我不是 struts2 defeloper,所以我的建议可能不正确。不过,您可以尝试直接在navigatorEditOption中包含内联 JavaScript 代码:

navigatorViewOptions="
                {
                    viewPagerButtons:false,
                    recreateForm: true,
                    checkOnUpdate: true,
                    beforeShowForm: function ($form) {
                        alert("inside of beforeShowForm function");
                    }
                }"

它看起来接近文档页面中的代码。我希望它会奏效。

或者,您可以定义一些全局函数,例如

<script type="text/javascript">
    var myBeforeShowForm = function ($form) {
            alert("inside of beforeShowForm function");
        };
</script>

myBeforeShowForm并在navigatorEditOption中使用 global :

navigatorViewOptions="
                {
                    viewPagerButtons:false,
                    recreateForm: true,
                    checkOnUpdate: true,
                    beforeShowForm: myBeforeShowForm
                }"

(与页面datePick上的函数代码对比)

于 2013-03-25T13:55:26.930 回答