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
145
BoundCheckBoxes in Grids
posted

I'm currently evaluating your controls for my company, but I'm having a few issues I'd like some help with please.  For example, I've added a BoundCheckBox to my webdatagrid, but I'm experiencing a few issues with it (code below)... 

Firstly, if I edit a row (by altering other data, not the BoundCheckBox itself), it sets itself to 'partial' (or what I presume is partial) once the update is committed.  If I navigate away from the page, then return, the edited row's BoundCheckBox is checked once more (so whatever is happening is not affecting the underlying data). 

Secondly, The BoundCheckBox is used to set the 'Active' status of the row (only 'Active' rows are displayed in the webdatagrid).  Is it possible to have the row hide if the user unchecks the 'Active' BoundCheckBox - preferably after asking the user if they're sure they wish to proceed?  If so, could someone provide a bit of guidance?

Finally, I've been using some of your competitor's third-party tools.  The thing I find strange about your grids is that it doesn't seem easy to add an 'edit' link to each row.  In turn, if you edit a row, there seems to be no 'save' or 'cancel' options.  Presently I have the updates committing when the row loses focus.  However, if the user were to make an edit, then navigate away from the page, that change would not occur.  Any suggestions on this?  Am I missing something obvious?

Code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ImpactAmendInfragistics.aspx.vb" Inherits="Brava.Content_Admin_ImpactAmendInfragistics"  %>

<%@ Register assembly="Infragistics2.Web.v11.1, Version=11.1.20111.1006, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" id="igClientScript">
<!--

function wdgImpact_Editing_RowUpdating(sender, eventArgs)
{
 ///<summary>
 ///
 ///</summary>
 ///<param name="sender" type="Infragistics.Web.UI.WebDataGrid"></param>
 ///<param name="eventArgs" type="Infragistics.Web.UI.CancelUpdateRowEventArgs"></param>

 //Add code to handle your event here.
}// -->
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:ScriptManager ID="ScriptManager1" runat="server"/>
   
        <asp:CheckBox ID="ChkIncludeInactive" runat="server" Text="Include Inactive Items" AutoPostBack="True" />

        <ig:WebDataGrid ID="wdgImpact"
            DataSourceID="dsImpactList"
            runat="server"
            AutoGenerateColumns="False"
            StyleSetName="Harvest"
            DataKeyFields="ImpactID"
            onrowupdating="wdgImpact_RowUpdating">
       
            <Columns>
                <ig:BoundDataField DataFieldName="ImpactID" Key="ImpactID" Hidden="true"/>
       <ig:BoundDataField DataFieldName="ImpactDesc" Key="ImpactDesc" Width="350" >
                    <Header Text="Impacts"></Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="SortOrder" Key="SortOrder" Width="60" >
                    <Header Text="Sort Order"></Header>
                </ig:BoundDataField>
       <ig:BoundCheckBoxField DataFieldName="Active" Header-Text="Active" DataType="System.Boolean" Key="Active" Width="60" >
                    <Header Text="Active"></Header>
                </ig:BoundCheckBoxField>
      </Columns>
       
            <behaviors>

            <%-- Activation must be enabled to set focus on a row --%>
            <ig:Activation Enabled="true"/>

                <ig:EditingCore Enabled="True"  >
                    <behaviors>
                        <ig:CellEditing Enabled="True" EditModeActions-MouseClick="Single" >
                            <ColumnSettings>
                                <ig:EditingColumnSetting ColumnKey="ImpactID" ReadOnly="true" />
                            </ColumnSettings>
                        </ig:CellEditing>
                    </behaviors>
                </ig:EditingCore>
            </behaviors>
       
        </ig:WebDataGrid>

        <asp:SqlDataSource runat="server" ID="dsImpactList" ProviderName="System.Data.SqlClient"
      SelectCommand="ImpactList" SelectCommandType="StoredProcedure"
            UpdateCommand="ImpactAmend"  UpdateCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter Name="ShowActiveOnly" Type="Boolean" DefaultValue="true"/>
                <asp:Parameter Name="ShowBlankentry" Type="Boolean" DefaultValue="false"/>
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="ImpactID" Type="Int32" />
                <asp:Parameter Name="ImpactDesc" Type="String" />
                <asp:Parameter Name="SortOrder" Type="Int32" />
                <asp:Parameter Name="Active" Type="Boolean" />
            </UpdateParameters>
  </asp:SqlDataSource>
   
    </div>
    </form>
</body>
</html>

  • 33839
    Suggested Answer
    posted

    Hi MartinWright6,

    I checked out your first issue.  It actually is a bug.  I have submitted it internally as 81517.  I've already fixed it and it should be available in the next Service Release.  If it is very critical, you could work around it by handling client side row updated.  Then for checkbox cells, call cell.set_value(true, 1) or cell.set_value(false, 0) or cell.set_value(null, 2).  The second value is the check state.

    For your second issue, you could use filtering where you filter the data source by checked for the boolean field.  Then after the checkbox is updated (after confirming), commit the update with editingCore.commit() and the row will be gone.

    Your last issue can be solved by using templated columns and putting in buttons or links to enter edit mode or save the changes.

    regards,

    David Young