This is a migrated thread and some comments may be shown as answers.

GridTemplateColumn CheckBox problem

3 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shahryar Ali
Top achievements
Rank 1
Shahryar Ali asked on 22 Jun 2010, 09:05 PM
The problem I have is that when i do a client-side rebind of the rows in a grid (using a webservice call), the GridTemplateColumn which contains checkboxes, does NOT refresh.  The data rows populate properly with no problem.  However, the number of checkboxes, as well as their state, are not affected by the rebind.  They are actually in exactly the same state as before the rebind.  I have tried a number of workarounds, none of which have worked.

I have some server-side activity that toggles the visible property of some of the rows prior to the rebind, but I don't think that should affect the behavior of the grid.  The following is done from a button click:

  .
  .
  .

 

var retval = ADAdvisor.ws.ADAdvisorMaintService.InvestorAccountsForCF(parseInt(currInvID.value), UpdateAccountList);

 

}

 

 


function
UpdateAccountList(result) {

 

 

var tableView = $find("<%= radGridAccounts.ClientID %>").get_masterTableView();

 

 

 

tableView.set_dataSource(result);

tableView.dataBind();

}

 

 



And, here is the grid with the template column checkbox:

 

<telerik:RadGrid ID="radGridAccounts" runat="server" Width="480px" Height="300px" Skin="Black" AllowMultiRowSelection="true" >

 

<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="True" >

 

 

 

<Selecting AllowRowSelect="true" UseClientSelectColumnOnly="false" />

 

 

 

<Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" />

 

 

 

</ClientSettings>

 

 

 

 

 

 

<MasterTableView AutoGenerateColumns="false" Font-Size="Larger" DataKeyNames="UserID,InvAcctID,AcctTypeCode" NoMasterRecordsText="All Accounts Assigned to Cash Flows..." >

 

 

 

 

<Columns>

 

<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Select for<br/>Cash Flow" >

 

 

 

<ItemTemplate>

 

 

 

<asp:Panel ID="Panel1" runat="server" >

 

 

 

 

 

 

<asp:CheckBox ID="chkBoxCFAccts" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="AccountChecked" />

 

 

 

 

</asp:Panel>

 

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn  DataField="AcctDesc"

                         

HeaderText="Account Description:"

 

                         

SortExpression="AcctDesc"

 

                         

UniqueName="AcctDesc"

 

                     

HeaderStyle-Width="200px" />

 

 

<telerik:GridBoundColumn  DataField="CurrBalance"

 

 

                            HeaderText="Balance:"

 

                             

SortExpression="CurrBalance"

 

 

                            UniqueName="CurrBalance"

 

                            HeaderStyle-Width="90px" />

 

<telerik:GridBoundColumn DataField="AcctTypeName"

 

                             

HeaderText="Account Type:"

 

                             

SortExpression="AcctTypeName"

 

                             

UniqueName="AcctTypeName"

 

                             

HeaderStyle-Width="100px" />

 

 

<telerik:GridBoundColumn DataField="UserID"

 

                              

HeaderText="UserID:"

 

                             

Visible="false" />

 

 

<telerik:GridBoundColumn DataField="InvAcctID"

 

                             

HeaderText="InvAcctID:"

 

                             

Visible="false" />

 

 

<telerik:GridBoundColumn DataField="AcctTypeCode" 
                                HeaderText="AcctTypeCode:"

 

 

 

                                Visible="false" />

 

 

 

</Columns>

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

 

 

 


I'm sure I am missing something simple, but I just can't solve this one.

Thanks,
Shahryar

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 23 Jun 2010, 03:27 PM
Hi Shahryar,

If you are changing the number of grid items that are rendered after the client-side rebind, note that this is not supported in RadGrid. Particularly, with client-side databinding, the content inside template columns cannot be duplicated into new rows that may appear. Therefore, with template columns, you should have more rows after client-rebind than initially.

If this is not the case with your scenario, or if you meant something else, could you, please, clarify.

Best wishes,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Shahryar Ali
Top achievements
Rank 1
answered on 23 Jun 2010, 03:40 PM
Yes, I am finding that there is a mis-match of rows.  The template column has two checked boxes, for example, after the client-side rebind, even though 4 rows came back from the webservice. 

So, you are saying that I should use server-side binding instead?  One option would be to use an AjaxPanel to update the grid, I guess.  Any other ideas on how best to do this would also be appreciated.

Thanks for your quick response on this.

Shahryar
0
Veli
Telerik team
answered on 24 Jun 2010, 12:11 PM
Hello Shahryar,

If the grid originally rendered with 2 rows, and after a client-side rebind there are now 4 rows, it is then expected that the newly added rows do not have their template column cell content duplicated. One option is to manually add the missing content of the template columns when the row is databound. You can use RadGrid's client-side OnRowDataBound event to get the row that is currently bound and insert content in its template cell. A similar approach is the RadGrid with programmatic client-side databinding demo you can refer to. In there, you can note the RadGrid1_RowDataBound function which is the event handler of the client OnRowDataBound grid event. The function is used to style the TitleOfCourtesy cell in each row. You can use a similar approach to actually insert content into the cell.

On the other hand, as you noted, you can use server-side databinding with AJAX, which is a completely different approach.

Sincerely yours,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Shahryar Ali
Top achievements
Rank 1
Answers by
Veli
Telerik team
Shahryar Ali
Top achievements
Rank 1
Share this question
or