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
1106
Template Columns and Adding a new row.
posted

I have a bound template column with a checkbox in it.  ( Works OK for existing Rows )

 

 

 

 

 

 

 

<ig:TemplateDataField Key="ControlInPlace" Width="20px"><ItemTemplate>

 

 

<asp:CheckBox ID="chkControlInPlace" runat="server" Checked='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "ControlInPlace")%>'

/></ItemTemplate><Header Text="InP" /></ig:TemplateDataField>

But when I click in the cell of the Add New Row Row, in that colum, it does not give me the checkbox. In face it does nothinng.

What am I missing ?

Parents Reply
  • 19693
    posted in reply to Terry
    Hello soberly,
     
    You should add the onclick client event as an attribute to the CheckBox .
     
    You can do this inside the implementation of InstantiateIn :
     
     
    or inside RowInitialize event : 
     
    protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
     
        {
     
            CheckBox chkBox = (CheckBox)e.Row.Items[0].FindControl("CheckBox1");
     
            chkBox.Attributes.Add("onclick", "return doCommit();");       
     
        }
     
    Inside this JS function you should simulate update  and commit the EditingCore behavior:  
     
            function doCommit() {
     
                var grid = $find('<%= WebDataGrid1.ClientID %>');
     
    // the second cell is not templated one
     
                var cellValue = grid.get_behaviors().get_activation().get_activeCell().get_row().get_cell(1).get_value();
     
                grid.get_behaviors().get_activation().get_activeCell().get_row().get_cell(1).set_value(cellValue);
     
                grid.get_behaviors().get_editingCore().commit();
     
            } 
     
     
    This should be done because templated field is not bound to data source and the WebDataGrid doesn't "know" that the value of the checkbox has been changed.  
     
    And last but not least you need to handle RowUpdating event in order to make the invocation of commit() work.
      
    Please let us know if you need further assistance regarding this.
Children
No Data