Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
875
Postback OnRowAdding each time exit a cell
posted

Hello

I need to generate a postback when exit of a cell in RowAdding. I achieved something like this, with event RowUpdating. I did, in page aspx:

<asp:UpdatePanel runat="server" ID="SampleUpdatePanel">
<ContentTemplate>

<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyFields="OrderID" OnRowUpdating="WebDataGrid1_RowUpdating">

.

.

<Behaviors>
<ig:Activation>
</ig:Activation>
<ig:EditingCore AutoCRUD="False">
<Behaviors>
<ig:CellEditing>
<CellEditingClientEvents ExitedEditMode="WebDataGrid1_CellEditing_ExitedEditMode" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
<ig:Selection CellClickAction="Row" RowSelectType="Single">
</ig:Selection>
<ig:RowSelectors>
</ig:RowSelectors>
</Behaviors>

.

.

</ig:WebDataGrid>

</ContentTemplate>
</asp:UpdatePanel>

<script type="text/javascript">
function WebDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs) {

__doPostBack('<%= SampleUpdatePanel.ClientID %>', '');
}

</script>

Therefore, with this, it generates a postback every time it exits to edit a cell (any cell, not necessarily the whole row) and enters in the following event:

protected void WebDataGrid1_RowUpdating(object sender, RowUpdatingEventArgs e)
{

//My code

}

This is okay, because it's just what I need.

Now, I need to make the same, but in this case, in a RowAdding event. I did something like this, in page aspx:


<asp:UpdatePanel runat="server" ID="SampleUpdatePanel">
<ContentTemplate>

<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyFields="OrderID" OnRowUpdating="WebDataGrid1_RowUpdating" OnRowAdding="WebDataGrid1_RowAdding">

.

.

<Behaviors>

<ig:Activation>
</ig:Activation>
<ig:EditingCore AutoCRUD="False">
<Behaviors>
<ig:CellEditing>
<CellEditingClientEvents ExitedEditMode="WebDataGrid1_CellEditing_ExitedEditMode" />
</ig:CellEditing>
<ig:RowAdding>
<AddNewRowClientEvents ExitedEditMode="WebDataGrid1_RowAdding_ExitedEditMode" />
</ig:RowAdding>
</Behaviors>
</ig:EditingCore>
<ig:Selection CellClickAction="Row" RowSelectType="Single">
</ig:Selection>
<ig:RowSelectors>
</ig:RowSelectors>
</Behaviors>

.

.

</ig:WebDataGrid>

</ContentTemplate>
</asp:UpdatePanel>

<script type="text/javascript">
function WebDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs) {

__doPostBack('<%= SampleUpdatePanel.ClientID %>', '');
}

function WebDataGrid1_RowAdding_ExitedEditMode(sender, eventArgs) {
__doPostBack('<%= SampleUpdatePanel.ClientID %>', '');
}

</script>


But, in this case, it generates a postback (I know it because put a breakpoint in Page_Load()) every time it exits of a cell (in The last row is used to insert or add), that's ok, but NOT enters in the following event:

protected void WebDataGrid1_RowAdding(object sender, RowAddingEventArgs e)
{
//My code
}

I need to enter into this event each time it leaves of a cell (not whole row) within the row to add (in The last row is used to insert or add).
What is happened? Why in this case, not enter in the event WebDataGrid1_RowAdding()?
Can you help me, please?
Any suggestions?


Thanks.
Geovanny Domínguez

Parents
No Data
Reply
  • 17590
    Verified Answer
    Offline posted

    Hello Geovanny Dominguez,

    Thank you for contacting Infragistics.

    What I can suggest for your scenario is adding the row programatically in RowAdding_ExitedEditMode handler. This  will cause a postback itself and calling __doPostBack function would not be necessary. This can be done as following:

    function WebDataGrid1_RowAdding_ExitedEditMode(sender, eventArgs)

    {

      var row = eventArgs.getCell().get_row();

       var itemArray = new Array();

       for (var i = 0; i < row.get_cellCount; i++) {

            itemArray[i] = row.get_cellCount();

        }

        sender.get_rows().add(itemArray);

    }

    Feel free to contact me if you have any additional questions concerning this matter.

     

Children