2012-01-11 19 views
0

私はJQGridでCRUDを実装しようとしています。しかし、私は次の問題が生じています:CRUD JQGridの操作

-rowsが

  • 削除行はEditDialogSettings.ReloadAfterSubmitをfalseに設定してもして、ポストバックが発生し、[インラインモードでのみ可能]別途ボタンを追加使用して追加することはできません。
  • インライン編集後に追加された行のみを削除します。どのようにクライアント側の行を削除することは可能ですか?

グリッドをページの読み込みにバインドする必要があります。それ以降のすべての編集は、クライアント側でのみ行う必要があります。フォームが最終的に提出されると、グリッドの変更が処理されます。

this linkで提供されているドキュメントに従っていますが、実装できません。

この問題に関するお手伝いをさせていただきます。


更新:

<%@ Register Assembly="Trirand.Web" Namespace="Trirand.Web.UI.WebControls" TagPrefix="trirand" %> 
<trirand:JQGrid ID="XYZ" runat="server" Width="700px" showToolBar="true"> 
<columns> 
<trirand:JQGridColumn DataField="AA" HeaderText="AA" Width="20" Editable="true" DataType="local"/> 
<trirand:JQGridColumn DataField="BB" HeaderText = "BB" Width ="50" Editable="true" DataType="local" /> 
<trirand:JQGridColumn DataField="CC" HeaderText ="CC" Width = "20" Editable="true" DataType="local"/> 
</columns> 
<ClientSideEvents RowDoubleClick ="editRow" />  
<ToolBarSettings ShowInlineAddButton="true" ShowInlineCancelButton="true" ShowDeleteButton="true" /> 
</trirand:JQGrid> 
<script type="text/javascript"> 
    var LastSelection; 
    function editRow(id) { 
    if (id) { 
     var grid = jQuery("#<%= XYZ.ClientID %>"); 
     grid.restoreRow(LastSelection); 
     grid.editRow(id, true); 
     LastSelection = id; 
} 
} 
</Script> 

を私は一番上の行を追加し、インライン編集を行うことができる午前: ここでは、私が書かれているサンプルコードです。しかし、データバインディングが完了した後、テーブルXYZに表示されている行を削除することはできません。私はこのコードがあなたに問題に関する考えを与えることを願っています。 ありがとう!

+1

サポートフォーラムを試しましたか?これは有料の商品ですか? http://www.trirand.net/forum/ – CrazyDart

答えて

0

jqGridとのスタートは最後にiが「ローカル」

変更プロパティのデータ型はで、いくつかの方法を

jQuery("<GridName>" or this).jqGrid(
    { datatype: "local", 
    colNames:['column_title_0','column_title_1','column_title_2'], 
    colModel:[ {name:'column0',index:'column0', editable:false,editoptions:{readonly:true,size:10}}, 
       {name:'column1',index:'column1', editable:false,editoptions:{readonly:true,size:10}}, 
       {name:'column2',index:'column2', editable:false,editoptions:{readonly:true,size:10}}], 
    viewrecords: true, 
    width: 400, 
    mType: "POST", 
    caption:'JQGrid review', 
    height: '50px', 
    scroll: 1 
    } 
); 

ゲット行、列を作成し、それを理解することができますいくつかのハードが、でしたid

 rowData = $(<Grid name or this for current grid>).jqGrid('getRowData',rowId); 
     if(rowData) 
     { 
     rowData.Property 
     } 

行を追加する

同上

$("<grid id>" or this).jqGrid('delRowData',rowId); 
によって
$(<grid id> or this).jqGrid('addRowData', <Here.Model.Id>, <object with all properties>); 

行削除

現在の行が

var selRowIndex = $("<grid id>" or this).jqGrid('getGridParam','selrow'); 

を選択し、私はそれがここでは良い例に

+0

返信いただきありがとうございます。私はすでにdataType = "local"を設定しています。しかし、それは私のために働いていません。私はhttp://trirand.com/blog/jqgrid/jqgrid.htmlに示すデモに従っています。私はインラインメソッドを使用しています。だから私は新しい行を追加して削除することができます。しかし、データバインド後にJqgridで取得した行を削除することはできません。私の問題を簡素化するための提案は高く評価されます。 – user1144097

+0

あなたの質問を更新し、問題の特定のものをあなたのコードに入れてください。それだけで私たちはわずかなアイデアを持つことができます –

0

を持っているあなたにhttp://trirand.com/blog/jqgrid/jqgrid.htmlのためのターンをお勧めします、私が書かれているサンプルコードであります:

<%@ Register Assembly="Trirand.Web" Namespace="Trirand.Web.UI.WebControls" TagPrefix="trirand" %> 
<trirand:JQGrid ID="XYZ" runat="server" Width="700px" showToolBar="true"> 
<columns> 
<trirand:JQGridColumn DataField="AA" HeaderText="AA" Width="20" Editable="true" DataType="local"/> 
<trirand:JQGridColumn DataField="BB" HeaderText = "BB" Width ="50" Editable="true" DataType="local" /> 
<trirand:JQGridColumn DataField="CC" HeaderText ="CC" Width = "20" Editable="true" DataType="local"/> 
</columns> 
<ClientSideEvents RowDoubleClick ="editRow" />  
<ToolBarSettings ShowInlineAddButton="true" ShowInlineCancelButton="true" ShowDeleteButton="true" /> 
</trirand:JQGrid> 
<script type="text/javascript"> 
    var LastSelection; 
    function editRow(id) { 
    if (id) { 
     var grid = jQuery("#<%= XYZ.ClientID %>"); 
     grid.restoreRow(LastSelection); 
     grid.editRow(id, true); 
     LastSelection = id; 
} 
} 
</Script> 

インライン編集が可能です。上部に行を追加します。しかし、データバインディングが完了した後、テーブルXYZに表示されている行を削除することはできません。私はこのコードがあなたに問題に関する考えを与えることを願っています。 ありがとう!

関連する問題