Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
173 views
I have a RadGrid within a RadWindow. The Grid actually lives in a separate ASPX file that is called into the RadWindow. The issue I'm having is that once I go into insert mode I can't go into edit mode unless I close my RadWindow and reopen it. If I choose edit mode first I have no issues. It only happens after I go into insert mode at any point, even if I don't actually insert a record.

On a side note I also have the issue that my insert popup window won't close after clicking the "Save" button.

Below is my code:

ASPX

<telerik:RadAjaxLoadingPanel ID="editDetailsLoadingPanel" runat="server" Skin="Vista" Transparency="30" />
<telerik:RadAjaxPanel ID="editDetailsPanel" runat="server" LoadingPanelID="editDetailsLoadingPanel">
                    <table>
                        <tr>
                            <td><asp:Label ID="editDetailsCostCtrLbl" Text="Cost Center:" runat="server" /></td>
                            <td><telerik:RadTextBox ID="editDetailsCostCtrTxt" runat="server" EmptyMessage="Enter Cost Center"/></td>
                        </tr>
                        <tr>
                            <td><asp:Label ID="editDetailsAuxLocLbl" Text="Aux Location: " runat="server" /></td>
                            <td><telerik:RadTextBox ID="editDetailsAuxLocTxt" runat="server" EmptyMessage="Enter Aux Location"/></td>
                        </tr>
                        <tr>
                            <!-- START PAR VALUE REGION -->
                            <td colspan="2">
                                <asp:Label ID="editDetailsParValueGridLbl" Text="Set Par Values" runat="server" />
                                <telerik:RadGrid ID="itemsParValueGrid" runat="server" AutoGenerateColumns="false" AllowPaging="true" Width="500px"
                                OnNeedDataSource="itemsParValueGrid_NeedDataSource" OnItemCommand="itemsParValueGrid_ItemCommand" AllowAutomaticUpdates="false" AllowAutomaticInserts="false">
                                    <MasterTableView CommandItemDisplay="Top" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true">
                                        <NoRecordsTemplate>
                                            <div>There are no records to display</div>
                                        </NoRecordsTemplate>
                                        <Columns>
                                            <telerik:GridEditCommandColumn />
                                            <telerik:GridBoundColumn UniqueName="ID" DataField="ID" Visible="false" />
                                            <telerik:GridBoundColumn UniqueName="Description" DataField="Description" HeaderText="Description" ReadOnly="true" />
                                            <telerik:GridBoundColumn UniqueName="PSNum" DataField="PSNum" HeaderText="PS #" ReadOnly="true"/>
                                            <telerik:GridBoundColumn UniqueName="Min" DataField="Min" HeaderText="Min" />
                                            <telerik:GridBoundColumn UniqueName="Max" DataField="Max" HeaderText="Max"  />
                                        </Columns>
                                        <EditFormSettings EditFormType="Template">
                                             <FormTemplate>
                                                <table>
                                                    <tr>
                                                        <td colspan="2">
                                                            <telerik:RadTextBox ID="parValueFilterTxt" EmptyMessage="Search PS # ..." runat="server" Width="200px" ClientEvents-OnKeyPress="filterList" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <telerik:RadListBox ID="RadListBox1" runat="server" AllowTransfer="true" Height="200px" Width="230px" SelectionMode="Multiple" TransferToID="RadListBoxTransfer" OnClientDropped="OnClientDroppedHandler" OnDeleted="RadListBox1_ItemDeleted" AutoPostBackOnTransfer="true"/>
                                                        </td>
                                                        <td>
                                                            <telerik:RadListBox ID="RadListBoxTransfer" runat="server" Height="200px" Width="200px" SelectionMode="Multiple" OnLoad="listboxload" OnDeleted="RadListBoxTransfer_ItemDeleted"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <telerik:RadButton ID="ParValueListBoxBtn" runat="server" Text="Save" CommandName="Save" />
                                                        </td>
                                                    </tr>
                                               </table>
 
                                            </FormTemplate>
                                        </EditFormSettings>
                                        <CommandItemSettings ShowRefreshButton="false" />
                                    </MasterTableView>
                                </telerik:RadGrid>
                            </td>
                            <!-- END PAR VALUE REGION -->
                        </tr>
                        <tr>
                            <td colspan="2"><telerik:RadButton ID="editDetailsUpdateBtn" runat="server" Text="Update" OnClick="editDetailsUpdateBtn_Click" AutoPostBack="true" /></td>
                        </tr>
                    </table>
</telerik:RadAjaxPanel>


C#


       private static List<string> addedParValue;
       private static List<string> removedParValue;
 
       protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               editDetailsAuxLocTxt.Text = AssetWhere.Admin_new.editDetailsAuxLoc;
               editDetailsCostCtrTxt.Text = AssetWhere.Admin_new.editDetailsCostCtr;
           }
       }
 
       protected void editDetailsUpdateBtn_Click(object sender, EventArgs e)
       {
           string AuxLocation = editDetailsAuxLocTxt.Text;
           string CostCenter = editDetailsCostCtrTxt.Text;
           string LocationID = AssetWhere.Admin_new.editDetailsLocationID;
 
           SqlCommand editDetailsUpdateCmd = new SqlCommand("UPDATE dbo.locations SET CostCenter='" + CostCenter + "', AuxLocationID='" + AuxLocation + "' WHERE ID ='" + LocationID + "'", connection);
           connection.Open();
           editDetailsUpdateCmd.ExecuteNonQuery();
           connection.Close();
 
       }
 
       protected void itemsParValueGrid_NeedDataSource(object sender, EventArgs e)
       {
           // Bind the Location Par Value Grid
           itemsParValueGrid.DataSource = GetDataTable("SELECT ItemParValues.ID, items.Description,items.CrossRefID as [PSNum],ItemParValues.Min,ItemParValues.Max FROM dbo.ItemParValues INNER JOIN dbo.items ON items.ID = ItemParValues.ItemID WHERE ItemParValues.LocationID = '" + AssetWhere.Admin_new.editDetailsLocationID + "' AND items.Tracking='1' ORDER BY [Min] ASC, [MAX] ASC, [PSNum] ASC");
       }
 
       public DataTable GetDataTable(string queryString)
       {
           using (SqlCommand cmd = new SqlCommand(queryString, connection))
           {
               SqlDataAdapter da = new SqlDataAdapter(cmd);
               DataTable dt = new DataTable();
               da.Fill(dt);
 
               return dt;
           }
       }
 
       protected void listboxload(object sender, EventArgs e)
       {
           // Search for controls
           RadListBox rlbSource = (RadListBox)((GridItem)((Control)sender).NamingContainer).FindControl("RadListBox1");
           RadListBox rlbDest = (RadListBox)((GridItem)((Control)sender).NamingContainer).FindControl("RadListBoxTransfer");
           RadTextBox txt = (RadTextBox)((GridItem)((Control)sender).NamingContainer).FindControl("parValueFilterTxt");
 
           // Command for getting the source and dest PS Numbers
           SqlCommand getSourcePSNum = new SqlCommand("SELECT items.CrossRefID, items.ID FROM dbo.items WHERE Tracking='1' AND CrossRefID NOT IN (SELECT items.CrossRefID FROM dbo.items inner join dbo.ItemParValues on items.ID = ItemParValues.ItemID WHERE ItemParValues.LocationID='" + AssetWhere.Admin_new.editDetailsLocationID + "' AND items.Tracking='1') ORDER BY items.CrossRefID ASC", connection);
           SqlCommand getDestPSNum = new SqlCommand("SELECT items.CrossRefID, items.ID FROM dbo.items inner join dbo.ItemParValues on items.ID = ItemParValues.ItemID WHERE ItemParValues.LocationID='" + AssetWhere.Admin_new.editDetailsLocationID + "' AND items.Tracking='1' ORDER BY items.CrossRefID ASC", connection);
 
           // Add Source PS Numbers to ListBox
           connection.Open();
               SqlDataReader sourceRdr = getSourcePSNum.ExecuteReader();
               while (sourceRdr.Read())
               {
                   rlbSource.Items.Add(new RadListBoxItem(sourceRdr.GetString(0), sourceRdr.GetGuid(1).ToString()));
               }
               sourceRdr.Close();
 
               // Add Dest PS Numbers to ListBox
               SqlDataReader destRdr = getDestPSNum.ExecuteReader();
               while (destRdr.Read())
               {
                   rlbDest.Items.Add(new RadListBoxItem(destRdr.GetString(0), destRdr.GetGuid(1).ToString()));
               }
               destRdr.Close();
           connection.Close();
 
           // Register Javascript for the TextBox
           string script = "var listbox;var filterTextBox;function pageLoad(){listbox = $find('" + rlbSource.ClientID  + "');filterTextBox = document.getElementById('" + txt.ClientID + "');listbox._getGroupElement().focus();}function OnClientDroppedHandler(sender, eventArgs){eventArgs.get_sourceItem().set_text(clearTextEmphasis(eventArgs.get_sourceItem().get_text()));}function filterList(){clearListEmphasis();createMatchingList();}function clearListEmphasis(){var re = new RegExp('</{0,1}em>', 'gi');var items = listbox.get_items();var itemText;items.forEach(function(item){itemText = item.get_text();item.set_text(clearTextEmphasis(itemText));})}function clearTextEmphasis(text){var re = new RegExp('</{0,1}em>', 'gi');return text.replace(re, '');}function createMatchingList(){var items = listbox.get_items();var filterText = filterTextBox.value;var re = new RegExp(filterText, 'i');items.forEach(function(item){var itemText = item.get_text();if (itemText.toLowerCase().indexOf(filterText.toLowerCase()) != -1){item.set_text(itemText.replace(re, '<em>' + itemText.match(re) + '</em>'));item.set_visible(true);}else{item.set_visible(false);}})}";
           ScriptManager.RegisterStartupScript(this, this.GetType(), "key22", script, true);
       }
 
       protected void itemsParValueGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
       {
           if (e.CommandName == RadGrid.InitInsertCommandName)
           {
               e.Item.OwnerTableView.EditMode = GridEditMode.PopUp;
               e.Item.OwnerTableView.EditFormSettings.PopUpSettings.Modal = true;
               e.Item.OwnerTableView.EditFormSettings.PopUpSettings.Width = 500;
               e.Item.OwnerTableView.EditFormSettings.PopUpSettings.Height = 300;
               e.Item.OwnerTableView.EditFormSettings.InsertCaption = "Add/Remove Item ParValue Tracking";
           }
           else if (e.CommandName == RadGrid.EditCommandName)
           {
               e.Item.OwnerTableView.EditMode = GridEditMode.InPlace;
           }
           else if (e.CommandName == RadGrid.UpdateCommandName)
           {
               GridEditableItem editedItem = e.Item as GridEditableItem;
 
               TextBox parValueDescription = (TextBox)editedItem["Description"].Controls[0];
               TextBox parValuePSNum = (TextBox)editedItem["PSNum"].Controls[0];
               TextBox parValueMin = (TextBox)editedItem["Min"].Controls[0];
               TextBox parValueMax = (TextBox)editedItem["Max"].Controls[0];
               TextBox parValueID = (TextBox)editedItem["ID"].Controls[0];
 
               SqlCommand updateParValues = new SqlCommand("UPDATE dbo.ItemParValues SET Min='" + parValueMin.Text + "', Max='" + parValueMax.Text + "' WHERE ID='" + parValueID.Text + "' AND LocationID='" + AssetWhere.Admin_new.editDetailsLocationID + "'", connection);
 
               connection.Open();
               updateParValues.ExecuteNonQuery();
               connection.Close();
           }
 
           else if (e.CommandName == "Save")
           {
               // Set variables
               int i = 0;
               int x = 0;
               Guid ParValueID = new Guid();
 
               // Setup search
               GridEditableItem editedItem = e.Item as GridEditableItem;
 
               RadListBox rlbSource = (editedItem.FindControl("RadListBox1") as RadListBox);
               RadListBox rlbDest = (editedItem.FindControl("RadListBoxTransfer") as RadListBox);
 
               while (addedParValue != null && i < addedParValue.Count())
               {
                   ParValueID = Guid.NewGuid();
 
                   // Insert new parvalues
                   connection.Open();
                   SqlCommand insertParValues = new SqlCommand("INSERT INTO dbo.ItemParValues (ID, LocationID, ItemID, CriticalLevel, Min, Max) VALUES ('" + ParValueID.ToString() + "', '" + AssetWhere.Admin_new.editDetailsLocationID + "', '" + addedParValue[i] + "', '0', '0', '0')", connection);
                   insertParValues.ExecuteNonQuery();
                   connection.Close();
                   i++;
               }
 
               while (removedParValue != null && x < removedParValue.Count())
               {
                   connection.Open();
                   // Remove old parvalues
                   SqlCommand deleteParValues = new SqlCommand("DELETE FROM dbo.ItemParValues WHERE ItemID='" + removedParValue[x] + "' AND LocationID='" + AssetWhere.Admin_new.editDetailsLocationID + "'", connection);
                   deleteParValues.ExecuteNonQuery();
                   connection.Close();
                   x++;
               }
 
 
                
           }
       }
 
       protected void RadListBox1_ItemDeleted(object sender, RadListBoxEventArgs e)
       {
           // Initialize List
           addedParValue = new List<string>();
           removedParValue = new List<string>();
 
           // Clear list so we can start fresh
           addedParValue.Clear();
 
           // Add all inserted items to list
           foreach (RadListBoxItem item in e.Items)
           {
               // Check to see if it already exists in the list
               if (!addedParValue.Contains(item.Value.ToString()))
                   addedParValue.Add(item.Value.ToString());
 
               // Remove the value if it exists in the source list
               // needed if you move a value back and forth in one session
               if (removedParValue.Contains(item.Value.ToString()))
                   removedParValue.Remove(item.Value.ToString());
           }
       }
 
       protected void RadListBoxTransfer_ItemDeleted(object sender, RadListBoxEventArgs e)
       {
           // Initialize List
           addedParValue = new List<string>();
           removedParValue = new List<string>();
 
           // Clear list so we can start fresh
           removedParValue.Clear();
 
           // Add all inserted items to list
           foreach (RadListBoxItem item in e.Items)
           {
               // Check to see if it already exists in the list
               if (!removedParValue.Contains(item.Value.ToString()))
                   removedParValue.Add(item.Value.ToString());
 
               // Remove the value if it exists in the source list
               // needed if you move a value back and forth in one session
               if (addedParValue.Contains(item.Value.ToString()))
                   addedParValue.Remove(item.Value.ToString());
           }
       }
   }


Any help is greatly appreciated.
Pavlina
Telerik team
 answered on 09 Aug 2011
7 answers
137 views
Hi there

I have a RadTreeView which binds to a HierarchicalDataSource fine, and I can instantiate a template for the node OK too. The template consists of a RadAjaxPanel that contains an ASCX user control. This all works fine too. My problem is I want to databind a Label web control in the templates' user control to the Content field of the dataitem for each node.

Because the dataitem is only available in the NodeDataBound handler, I reckon I need to get a reference to the Label in the NodeDataBound handler. The problem is, the NodeTemplate property is 'Nothing' when I examine the properties of e.Node from the event arguments. Therefore I don't think I can get a reference to controls in the template at this stage.

Can someone advise, how should I get a reference to the node template at the same time as I can get to the nodes DataItem - the two never seem to be populated at the same time.

Thanks if you can help.

Regards
 
Plamen
Telerik team
 answered on 09 Aug 2011
6 answers
96 views
Hi all,

my application has ASP and ASP.Net pages,all asp.net pages has  a user-Control which neary has 40 rad-combo in it..

My Problem is after  navigating few pages in my application using Menu or links provided in the page then click the small arrow near browser back button  i can see only Previous page,because of this user is able to navigate back only  one time after that back button is getting Disbled.
example:
suppose that i have 4 pages logon,A,B,C and A is my landing page after login
in page A when i click arrow near  browser back button  then i can see login page
now im navigating to Page B from Page A, if i click arrow near  browser back button  then i can see only A inseted of A and Logon
now im navigating to Page C from Page B, if i click arrow near  browser back button  then i can see only B inseted of  B,A and Logon

on commenting  the code which binds data for rad-combo's and  trying the same seniro as above  can see all pages i navigated.
im Using radcombo.Bind() to bind data to these drop down

and one more thing is my user-Controls gets executed every time in the page so all the binding functionalty is all getting execcuting again...

 i am thinking because of increase in  page size this is happing.

as my applicaton has lot of reports,back button  is vey important to us
please help me fixing this.???

Thanks,Harin
Dimitar Terziev
Telerik team
 answered on 09 Aug 2011
1 answer
73 views
I have a ASP.NET Framework 4.0 web application that has a RadAjaxManager in the Master Page, and uses the AjaxSettings.AddAjaxSettings in the On PreRender method of the content page to load the Ajax settings.
I have two content placeholders One for a naviagation bar on the left, and one for content on the right.
The navigation bar is populated with a series of buttons and each button dynamically removes any previously loaded user control, and loads the user control associated with the button clicked. Every web user control that is added consists of multiple rad controls such as a tab strip and multi-page with more rad controls in the page view, etc.

Everything works perfectly for Firefox and Chrome, but in IE 9, when a button is clicked, I get a flicker of the background and after the control is loaded, none of the rad controls click events work.

I am using the latest Rad Controls for ASP.NET AJAX for ASP.NET 4.0.
I tried the 3.5 version previously.

Unfortunately, we use IE as our standard browser.

Any help with this would be greatly appreciated.

    Thank you,
    Chuck




License Developer
Top achievements
Rank 1
 answered on 09 Aug 2011
2 answers
100 views
Hi,

I am using RadFilterDateFieldEditor as custom field editor for date fields. I just want show the date in the filter texbox when you select the date from the datepicker. How do I do that? Is their any proprty that I can use?

Thanks,
Raji

Mira
Telerik team
 answered on 09 Aug 2011
1 answer
42 views
In IE 6 and 7, all buttons and Images scroll down ie they are moving with the scroll bar and mouse pointer. This works fine in IE 8 and Firefox.
We are using the latest version of telerik i.e v.2011.2.712.40.

What can be the reason for this?
Slav
Telerik team
 answered on 09 Aug 2011
3 answers
84 views
Hi,

I am planning to purchase the Telerik ASP.NET Ajax suite but was not sure whether to buy the $999 one which offers free 1 year upgrades or to buy the $799 one which is the same except for the 1 year upgrade part.

For me to decide this I would like to know what features are coming in next 1 year.

Can anyone help.

Thanks,
- Manoj

Sebastian
Telerik team
 answered on 09 Aug 2011
1 answer
49 views

Hi

Can i show the sum of all the series at the top of the stack.

Its an urgent requirement .

 

Is it possible for ASP.net AJAX as i have seen for silver light.

 

 

Thanks

 

Evgenia
Telerik team
 answered on 09 Aug 2011
1 answer
81 views

I have a question about removing a RadTagCloudItem. I have a TagCloud and i want it to behave like most clouds. For example, if i don't like a word in the cloud i want to right-click on the word and select from a pop-up menu remove it. And the word will be removing from the cloud i see(Client-side).

I have tried to click on the word i don't want and in server-side removing it, but it's very slow and it's not what i want. Because it's not obvious for someone else to click on the word in order to remove it.

Any propose?

Dobromir
Telerik team
 answered on 09 Aug 2011
2 answers
75 views
Hi,

I am trying to put a RibbonBar inside a table cell. The reason for this is that
I want to put things to the right of the ribbonbar.
When I run the page the RibbonBar is not sized correctly. It is too small and
all buttons is not visible.

I can not set any width in pixels, the content is dynamic.

Does anyone know if it is possible to put a ribbonbar inside a table cell?

<
table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td >
                <telerik:RadRibbonBar ID="RadRibbonBar1" runat="server"  Skin="Office2007">
                    <telerik:RibbonBarTab Text="Home">
                        <telerik:RibbonBarGroup >
                            <Items>                            
                                <telerik:RibbonBarButton Size="Medium" Text="Cut"  />
                                <telerik:RibbonBarButton Size="Medium" Text="Copy"  />                             
                            </Items>
                        </telerik:RibbonBarGroup>
                        <telerik:RibbonBarGroup >
                            <Items>                            
                                <telerik:RibbonBarButton Size="Medium" Text="Cut" />
                                <telerik:RibbonBarButton Size="Medium" Text="Copy"  />                             
                            </Items>
                        </telerik:RibbonBarGroup>
                        <telerik:RibbonBarGroup >
                            <Items>                            
                                <telerik:RibbonBarButton Size="Medium" Text="Cut" />
                                <telerik:RibbonBarButton Size="Medium" Text="Copy"  />                             
                            </Items>
                        </telerik:RibbonBarGroup>
                        <telerik:RibbonBarGroup >
                            <Items>                            
                                <telerik:RibbonBarButton Size="Medium" Text="Cut"  />
                                <telerik:RibbonBarButton Size="Medium" Text="Copy" />                              
                            </Items>
                        </telerik:RibbonBarGroup>
                        <telerik:RibbonBarGroup >
                            <Items>                            
                                <telerik:RibbonBarButton Size="Medium" Text="Cut"  />
                                <telerik:RibbonBarButton Size="Medium" Text="Copy"  />                             
                            </Items>
                        </telerik:RibbonBarGroup>
                    </telerik:RibbonBarTab>
                </telerik:RadRibbonBar>
            </td>
            <td style="background: red;">
                Right cell
            </td>
        </tr>
    </table>
Caesar
Top achievements
Rank 1
 answered on 09 Aug 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?