English 中文(简体)
如果在jqgrid中使用直线添加纽顿,如何确定违约数值
原标题:How to set default values if row is added using inline add button in jqgrid

Code below sets default values for new row if row is added using form. If row is added using jqGrid inline add button from toolbar, those methods are not called and default values are not set.

• 如何在网上添加与以下法典相同的逻辑?

var lastSelectedRow;
$grid.navGrid("#grid_toppager", { 
del: true,
add: true,
view: true,
edit: true
          }, 
          {},

       { 
       addedrow:  beforeSelected ,
       url:  /Grid/Add?_entity=Desktop ,
       beforeInitData: function () {
         // todo: how to call this method from inline add
         var rowid = $grid.jqGrid( getGridParam ,  selrow );
         if (rowid === null) {
           alert(  Select row before adding );
           return false;
           }
         },

       afterShowForm: function(formID) {
         // todo: how to set default values as this method sets from inline add
         var selRowData, 
            rowid = $grid.jqGrid( getGridParam ,  selrow );
         $( #  +  Recordtype  +  .FormElement ).val( Veerg );
         $( #  +  Nait2  +  .FormElement )[0].checked = true;
         selRowData = $grid.jqGrid( getRowData , rowid);
         $( #  +  Baas  +  .FormElement ).val(selRowData.Baas);
         $( #  +  Liigid  +  .FormElement ).val(selRowData.Liigid);
       }
       );


$grid.jqGrid( inlineNav ,  #grid_toppager , {
    addParams: {
        position: "beforeSelected", 
        rowID:  _empty ,
        useDefValues: true,
        addRowParams: {
            keys: true,
            onEdit :  onInlineEdit
        }
    },

    editParams: {
        editRowParams: {
            onEdit : onInlineEdit
            }
    },

   add: true,
   edit: false,
   save: true,
   cancel: true
}); 

function onInlineEdit(rowId) {
  if (rowId && rowId !== lastSelectedRow) {
        cancelEditing($grid);
        lastSelectedRow = rowId;
    }
  }

Update

I Trial Code

 $grid.jqGrid( inlineNav ,  #grid_toppager , {
    addParams: {
        position: "beforeSelected", 
        rowID:  _empty ,
        useDefValues: true,
        addRowParams: {
            keys: true,
            extraparam: { _dokdata: FormData },
            onSuccess : function (jqXHR) { 
alert( addp oncuss );
              jqXHRFromOnSuccess=jqXHR;
              return true;
              },
            afterSave: function (rowID) {
alert( afeesave addp  );
              cancelEditing($grid);
                  afterDetailSaveFunc(rowID,jqXHRFromOnSuccess);
              jqXHRFromOnSuccess=null; 
              },
            onError: errorfunc,
            afterRestore : setFocusToGrid,
            oneditfunc  : function (rowId) {
              var selRowData, selRowId ;
              if (rowId && rowId !== lastSelectedRow) {
                cancelEditing($grid);
                selRowId = $grid.jqGrid( getGridParam ,  selrow );
                if (selRowId ) {
                   selRowData = $grid.jqGrid( getRowData , selRowId ); 
                   $( #  + rowId +  _Reanr  ).val(selRowData.Reanr); 
                  }
                lastSelectedRow = rowId;
                }
             }
        }
    }
);

只打电话给定点。 • 如何在Surccess、Save、Error等方法上强制使用?

<><>Update 2

我在解答和审判时建议ith除阴道。

$.extend( jQuery.jgrid.inlineEdit, {
  addParams: { 
    position: "beforeSelected", 
    rowID:  <%= EntityBase.NewRowIdPrefix %> ,
    useDefValues: true,
    addRowParams: {
      keys: true,
      extraparam: { _dokdata: FormData },
      onSuccess : function (jqXHR) { 
        jqXHRFromOnSuccess=jqXHR;
        return true;
        },
      afterSave: function (rowID) {
              cancelEditing($grid);
              <% if (Model is RowBase ) { %>
                  afterDetailSaveFunc(rowID,jqXHRFromOnSuccess);
                <% } else { %>
                  afterGridSaveFunc(rowID,jqXHRFromOnSuccess);
                <% } %>
              jqXHRFromOnSuccess=null; 
              },
      onError: errorfunc,
      afterRestore : setFocusToGrid,
      oneditfunc : function (rowId) {
        if (rowId && rowId !== lastSelectedRow) {
          cancelEditing($grid);
          lastSelectedRow = rowId;
          }  
        } 
      }
    }
} );

本案不再逐条增加。 该法典的所有参数都被忽视。

最佳回答

您应使用<代码>defaultValue Property of the editoptions ,以便为新增加的行文设定默认值。 在现有文件中,你发现,这一选择只在形式编辑模块中有效:

The option can be string or function. This option is valid only in Form Editing module when used with editGridRow method in add mode. If defined the input element is set with this value if only element is empty. If used in selects the text should be provided and not the key. Also when a function is used the function should return value.

但是,如果你审查新的addRow。 方法:

  1. the default value of the useDefValues option is true
  2. the method do use (see here) the defaultValue property of the editoptions.

<>UPDATED: OK! 现在我看到你的问题。 您在<代码>editRowParams和<编码>上使用了单纯的错误特性。 更正如下:

$grid.jqGrid( inlineNav , topPagerSelector, {
    addParams: {
        position: "beforeSelected", 
        rowID:  _empty ,
        useDefValues: true,
        addRowParams: {
            keys: true,
            oneditfunc :  onInlineEdit
        }
    },
    editParams: {
        keys: true,
        oneditfunc: onInlineEdit
    },
   add: true,
   edit: false,
   save: true,
   cancel: true
});

此外,还可以使用新的。 <代码>keys,oneditfunc或在线编辑的其他参数。 该特征的实施并不完全正确,但你可以从光布(见here)中审查目前版本,并在jquery.jqGrid.src.js上作同样的修改。 无论如何,我建议使用$.jgrid.inlineEdit。 发表下版jqGrid之后的特征。 优点是,你可以轻松地设定以下选择:editRow,独立于职能的名称之外(inlineNav, actions Formatter or any other way)。

here,请提供更多信息,请你采取类似行动,。 这只能是一次。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.