<telerik:RadComboBox ID="rcbInitiated" runat="server" DataTextField="userName" MarkFirstMatch="true" DataValueField="eID" EnableLoadOnDemand="true" EnableAutomaticLoadOnDemand="true" ShowMoreResultsBox="false" EnableVirtualScrolling="false" OnClientDropDownClosed="OnClientDropDownClosed" EnableItemCaching="true"> <CollapseAnimation Duration="200" Type="OutQuint" /> <WebServiceSettings Path="~/ws/wsCFR.asmx" Method="GetEIDUserName" /> </telerik:RadComboBox><WebMethod()> _ Public Function GetUserIDUserName(ByVal context As RadComboBoxContext) As RadComboBoxData Return GetItems(context, "userID") End FunctionPublic Function GetItems(ByVal context As RadComboBoxContext, ByVal valueField As String) As RadComboBoxData Dim data As DataTable = GetData(context.Text) Dim comboData As New RadComboBoxData() Dim itemOffset As Integer = context.NumberOfItems Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count) comboData.EndOfItems = endOffset = data.Rows.Count Dim result As New List(Of RadComboBoxItemData)(endOffset - itemOffset) For i As Integer = itemOffset To endOffset - 1 Dim itemData As New RadComboBoxItemData() itemData.Text = data.Rows(i)("userName").ToString() itemData.Value = data.Rows(i)(valueField).ToString() result.Add(itemData) Next comboData.Message = GetStatusMessage(endOffset, data.Rows.Count) comboData.Items = result.ToArray() Return comboData End Functionprotected
void grdSystemComponents_ItemCreated(object sender, GridItemEventArgs e){
if
(e.Item is GridDataItem && e.Item.IsInEditMode || e.Item is GridFilteringItem)
{
foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
{
if ((column is GridBoundColumn) && !((GridBoundColumn)column).ReadOnly)
{
TextBox textBox = null;
if (e.Item is GridDataItem)
{
textBox = ((TextBox)((GridDataItem)e.Item)[column.UniqueName].Controls[0]);
textBox.Style["width"] = "90%";
textBox.Style["height"] = "11px";
textBox.Style["border"] = "0px";
textBox.Style["font-size"] = "11px";
} }
//Each column is assigned UniqueName as ID of respective Column
string headerID = column.HeaderText;
int count = dtHeaderInfo.Rows.Count;
for (int i = 0; i < count; i++)
{
if (headerID == dtHeaderInfo.Rows[i][0].ToString())
column.UniqueName = dtHeaderInfo.Rows[i][0].ToString();
} } } }
Here are my two Issues:
1) Since Grid is set up this way, I have no idea how to calculate Footer Total for each columns. Number of column changes depending on the selected Item on Combo Box.
2) I also need to update Caluculation as user will enter number on textboxes of the Grid. In the grid, there is a column called "Tot Num", as user enter numbers here I need to update other columns on same row, user can change it but can't exceed value of "Tot Num" column. If "Tot Number" is zero, should not allow to enter number.
I need to have database interaction for calculation? How do I go go to accomplish this? Your help is much appreciated.
thansk
Madhu
<script type="text/javascript">var uri = 'http://sampleurl/imp?type(img)g(111)a(222)' + new String(Math.random()).substring(2, 11);
document.write('<a id="a_manuallyadded" href="http://sampleurl/click?p=111&a=222&g=333"
target="_BLANK"><img id="i_manuallyadded" src="' + uri + '" border=0></a>'); </script><telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" FooterStyle-Width="100px" ShowFooter="true" OnNeedDataSource="RadGrid1_NeedDataSource" AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" OnItemDataBound="RadGrid1_ItemDataBound" DataSourceID="SqlDataSource1" OnItemUpdated="RadGrid1_ItemUpdated" AllowFilteringByColumn="true" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound" ExportSettings-OpenInNewWindow="true" ExportSettings-Pdf-AllowPrinting="true" OnItemCreated="RadGrid1_ItemCreated" ExportSettings-Pdf-PageTitle="Financial Record" Skin="Hay"> <PagerStyle Mode="NextPrevAndNumeric" /> <ExportSettings OpenInNewWindow="True"> <Pdf PageTitle="Financial Record"></Pdf> </ExportSettings> <MasterTableView Width="950px" CommandItemDisplay="TopAndBottom" DataKeyNames="BudgetId" EditMode="EditForms" CommandItemSettings-AddNewRecordText="Add New Record" DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False"> <CommandItemSettings AddNewRecordText="Add New Record"></CommandItemSettings> <Columns> <%--footer--%> <telerik:GridTemplateColumn UniqueName="footer1" DataField="footer1" ColumnEditorID="footerEditor" > <ItemTemplate> </ItemTemplate> <HeaderStyle Width="950px" /> <ItemStyle Width="950px" /> <FooterStyle Width="950px" /> <FooterTemplate> <h3><asp:Label runat="server" ID="lblBudgetSummary" >Budget Summary</asp:Label></h3> <table width="400px;"> <tr><td width="200px">Total</td><td width="200px"> <asp:Label ID="lblTotal" runat="server" Text='<%# Bind("Total2", "{0:F2}") %>'></asp:Label></td></tr> <tr><td>Food</td><td><asp:Label ID="lblFood" runat="server" Text='<%# Bind("Total2", "{0:F2}") %>'></asp:Label></td></tr> <tr><td>Transport</td><td> <asp:Label ID="lblTransport" runat="server"></asp:Label></td></tr> <tr><td>Communication</td><td><asp:Label ID="lblCommunication" runat="server"></asp:Label></td></tr> <tr><td>Residence</td><td><asp:Label ID="lblResidence" runat="server"></asp:Label></td></tr> <tr><td>Clothing</td><td><asp:Label ID="lblClothing" runat="server"></asp:Label></td></tr> <tr><td>Health</td><td><asp:Label ID="lblHealth" runat="server"></asp:Label></td></tr> <tr><td>Insurance</td><td> <asp:Label ID="lblInsurance" runat="server"></asp:Label></td></tr> <tr><td>Leisure</td><td><asp:Label ID="lblLeisure" runat="server"></asp:Label></td></tr> <tr><td>Education</td><td><asp:Label ID="lblEducation" runat="server"></asp:Label></td></tr> <tr><td>Other</td><td><asp:Label ID="lblOther" runat="server"></asp:Label></td></tr> </table> </FooterTemplate> </telerik:GridTemplateColumn> <%--edit button--%> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" > </telerik:GridEditCommandColumn> <%--User ID (Visible)--%> <%-- <telerik:GridBoundColumn DataField="UserId" HeaderText="UserId" SortExpression="UserId" Visible="false" UniqueName="UserId" > </telerik:GridBoundColumn>--%> <%--Budget ID (visible) --%> <%-- <telerik:GridBoundColumn DataField="BudgetId" HeaderText="BudgetId" SortExpression="BudgetId" Visible="false" UniqueName="BudgetId" > </telerik:GridBoundColumn>--%> <%--Create Date --%> <telerik:GridDateTimeColumn DataField="CreateDate" HeaderText="Date Added" SortExpression="CreateDate" ColumnEditorID="dtCreateDate" MinDate="01/01/2011" HtmlEncode="false" UniqueName="CreateDate" DataType="System.DateTime" DataFormatString="{0:dd/MMM/ yyyy}"> <HeaderStyle Font-Size="12px" /> <ItemStyle Font-Size="11px" /> </telerik:GridDateTimeColumn> <%--category ID--%> <telerik:GridDropDownColumn DataField="CategoryId" DropDownControlType="RadComboBox" HeaderText="Category" ListTextField="CategoryType" ListValueField="CategoryId" UniqueName="CategoryId" DataSourceID="SqlDataSource2"> </telerik:GridDropDownColumn> <%--record title--%> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description" EditFormColumnIndex="1" ColumnEditorID="GridTextBoxColumnEditor1"> </telerik:GridBoundColumn> <%--Amount--%> <telerik:GridNumericColumn DataField="Amount" HeaderText="Amount" SortExpression="Amount" DataFormatString="{0:C}" UniqueName="Amount" EditFormColumnIndex="1" ColumnEditorID="GridTextBoxColumnEditor3"> </telerik:GridNumericColumn> <%--Carry forward--%> <telerik:GridCheckBoxColumn DataField="CarryForward" HeaderText="Carry Forward" SortExpression="CarryForward" ColumnEditorID="chkCarryForward" UniqueName="CarryForward" EditFormColumnIndex="1"> </telerik:GridCheckBoxColumn> <%--delete row data popup--%> <telerik:GridButtonColumn ConfirmText="Delete this account?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> <ItemStyle HorizontalAlign="Center" /> </telerik:GridButtonColumn> </Columns> <%--Account Name Edit Form Settings--%> <EditFormSettings ColumnNumber="1" CaptionDataField="RecordId" CaptionFormatString="Edit properties of Account {0}"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> </telerik:RadGrid>protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode)//Check for Edit mode. Here its InPlace. { GridEditableItem editItem = (GridEditableItem)e.Item; RadComboBox combo = (RadComboBox)editItem["CategoryId"].Controls[0]; combo.AllowCustomText = true; combo.EmptyMessage = "=Select="; } if (e.Item is GridFooterItem) { GridFooterItem footer = ((GridFooterItem)e.Item); int index = RadGrid1.Columns.Count; footer["footer1"].ColumnSpan = 8; // footer["footer1"].Width = 10; }