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

[Solved] Client side update CommandItemTemplate from selected rows

5 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Soren
Top achievements
Rank 1
Soren asked on 28 Mar 2008, 05:44 PM

Hi!
I've read and read all day and I believe noone has written about how to update a for instance a label inside CommandItemTemplate client side when selecting some rows in the grid.
In my case I have

<
telerik:RadGrid ID="RadGrid1" runat="server"  AllowMultiRowSelection="true" >
<ClientSettings>
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView CommandItemDisplay="Top" DataKeyNames="Id" Width="100%">
<CommandItemTemplate>
<asp:Label ID="Totall" runat="server" ></asp:Label>
</CommandItemTemplate>
<Columns>

<
telerik:GridBoundColumn DataField="Id" HeaderText="Id" ReadOnly="True" UniqueName="Id" Visible="false">
</telerik:GridBoundColumn>

<
telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" SortExpression="Amount" UniqueName="Amount" DataFormatString="{0:N2}">
<HeaderStyle Width="50px" />
</telerik:GridBoundColumn>

<telerik:GridClientSelectColumn HeaderStyle-Width="20px" ItemStyle-Width="10px" UniqueName="Select1" />

</Columns>
</MasterTableView>
</telerik:RadGrid>

How do I get the selected amounts from each row and show the total selected amount in label "Total" in the CommandItemTemplate?  (and keep selected rows selected)
Thanks a million in advance and best regards.
Soren.

5 Answers, 1 is accepted

Sort by
0
Soren
Top achievements
Rank 1
answered on 30 Mar 2008, 05:26 PM
No ideas anyone?
I thought it could be done simply with javascript :-/

I've tried an example with ajax and server side updating a variable on postbacks by setting the GridClientSelectColumn with
((CheckBox)((GridDataItem)e.Item)["Select1"].Controls[0]).AutoPostBack = true;
on ItemCreated. But I can't find a way to update the Total label and keep the selected rows selected.
The updating is also a bit slow with ajax.

Thanks a million in advance and best regards.
Soren.
0
Sebastian
Telerik team
answered on 01 Apr 2008, 01:07 PM
Hi Soren,

For your convenience I have prepared a sample web site which illustrates how to attain the functionality you are searching for. The demo is uploaded in the code library section on our site:

http://www.telerik.com/community/code-library/submission/b311D-bchtcg.aspx

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Soren
Top achievements
Rank 1
answered on 03 Apr 2008, 09:15 AM
Thanks for your answer Stephen.
Foolish of me, but I forgot to mention I already had the postback solution. I'm searching for a solution where the aggregated value is updated instantly, when a row or checkbox is selected. Guess it's quite harder?

We've bought the Prometheus package yesterday anyway ;-)
Thanks in advance and best regards.
Soren.
0
Sebastian
Telerik team
answered on 03 Apr 2008, 09:45 AM
Hi Soren,

Let me know if I am missing something but the value in the command item label from the code library project is updated instantly with client script.

Best,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Soren
Top achievements
Rank 1
answered on 03 Apr 2008, 10:23 AM
ok!! Yeah!  I can see clearly now. I didn't run your code at first since it didn't run well after beeing upgrated to .net 3.5 in vs 2008. I just looked at the code and got blinded by the btn onclick event as I just assumed it was necesary.

I tried now without conversion and removed the sql datasource (as it gave an error) and made an accesdatasource to the included mdb. Now it just runs and runs..and well. Except for the button as it gives a "not well formed error" at this line:

result = result + Convert.ToInt32(gridItem(
"UnitPrice").Text.Substring(1, gridItem("UnitPrice").Text.Length - 1))
 
I guess the intension is just to write som output to a label, so I don't mind.
Thanks a million and best regards.
Soren.
Tags
Grid
Asked by
Soren
Top achievements
Rank 1
Answers by
Soren
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or