Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
242 views

I have a RadGrid that puts all rows in to editmode when the page loads, as outlined in the documentation using the PreRender event.  I have also configured an UpdateAll item command to enable updating all records at once, as outlined in "Performing Batch Updates".  The problem is that it updates all records even if no change was made.  Is there someway to mark a row as dirty and only run the update query if it has changed?
Any suggestions on how I can limit the update to only fire if a change to the row was made?

Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand  
        If e.CommandName = "UpdateAll" Then 
            For Each editedItem As GridEditableItem In RadGrid1.EditItems  
                Dim newValues As Hashtable = New Hashtable  
                e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem)  
                sdsSODetails.UpdateCommand = String.Format("UPDATE rx_srorder_extend SET STOP_NO='{0}', PLAN_REC_DATE='{1}', CONF_REC_DATE='{2}', CONF_NO='{3}', CONF_BY='{4}', CHANGED_BY='{6}' WHERE SRORDER_ID='{7}' IF @@ROWCOUNT = 0 INSERT INTO rx_srorder_extend (SRORDER_ID, PLAN_REC_DATE, CONF_REC_DATE, CONF_NO, CONF_BY, STOP_NO, CHANGED_BY) VALUES ('{7}', '{1}','{2}','{3}','{4}','{0}','{6}')", newValues("STOP_NO"), newValues("PLAN_REC_DATE"), newValues("CONF_REC_DATE"), newValues("CONF_NO"), newValues("CONF_BY"), newValues("SCHED_STATUS_ID"), newValues("CHANGED_BY"), editedItem.GetDataKeyValue("SRORDER_ID").ToString())  
               sdsSODetails.Update()  
            Next 
        End If 
    End Sub 
 
    Private Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadGrid1.PreRender  
        If Not IsPostBack Then 
            For Each item As GridItem In RadGrid1.MasterTableView.Items  
                If TypeOf item Is GridEditableItem Then 
                    Dim editableItem As GridEditableItem = CType(item, GridDataItem)  
                    editableItem.Edit = True 
                End If 
            Next 
            RadGrid1.Rebind()  
        End If 
    End Sub 
 
Princy
Top achievements
Rank 2
 answered on 08 Apr 2010
1 answer
77 views
I am using RadTextBox, RadNumericTextBox and RadMaskedTextBox with Skin="" and using RadFormDecorator to create rounded corners in accordance with your recommendation.
When I apply CssClass AlignRight { text-align:right; } the rounded corners disappear.
How else can this be done?
Regards
Harry
Dimo
Telerik team
 answered on 08 Apr 2010
2 answers
75 views
can we customize radmenu whose skin is windows 7. ?
Soumya Joseph
Top achievements
Rank 1
 answered on 08 Apr 2010
1 answer
73 views
I am looking for some advice on valid techniques for updating a column in a grid asynchronously with sort of notification. Here's the scoop...

I have a list of vendors in a grid (measured in the thousands). I want the ability to multi-select vendors and then kick off a task which verifies them via a server-side task. So, lets say that I select 20 vendors through multi-select. Then I click a "verify" button. I want this to initiate a task on the server which does the following:

. Sends the 20 rows to a server-side method (let's call it "ValidateRows")
. As ValidateRows iterates through the list I want the selected columns (in the grid) to initially show an hourglass or something.
. As the validity of any one row is determined the status changes visually in the grid
. Note that the per-row verification is not necessarily a quick thing (could take, say, 15-20 seconds each)
. I want the verifications to occur in parallel, rather than serialized, up to a maximum "thread count". So, if I send 20 rows maybe a thread count of 10 would mean that 10 are being checked at any one time.
. I don't want some server-side "service" waiting for all this. I want the verification task (the one that iterates through the sent rows on the server) to be initiated on demand.

Obviously Ajax looks like a good choice in terms of the visual treatment (in the grid) but I am not sure of the techniques I should use for the other elements of this.

I welcome any suggestions.

Thanks.

Mark
Mira
Telerik team
 answered on 08 Apr 2010
1 answer
120 views
Hi,
I have 2 radcombox, RadComboBox A and  RadComboBox B which the data in RadComboBox B is decided by the selection in RadCombobox A. Both the RadCombobox is in RadGrid.
When the grid go into  "Add Record "mode , i fail to populate the data in RadComboBox B for the first item in RadComboBox A.My coding is as below :

  <ajax:RadComboBox runat="server" ID="RadComboA" DataSource="<%# getApp() %>"  OnSelectedIndexChanged="BindSecondCombo" 
                    DataTextField="Selection"  AutoPostBack ="true" 
                    DataValueField="AppId"  
                    SelectedValue='<%# DataBinder.Eval(Container.DataItem, "AppId") %>'></ajax:RadComboBox> 
                    






Public Sub BindSecondCombo(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) 
 
        Dim radComboA As RadComboBox 
        Dim radComboB As RadComboBox 
        Dim editItem As GridDataInsertItem 
 
 
        radComboA = CType(sender, RadComboBox) 
        editItem = CType(radCombo1.NamingContainer, GridDataInsertItem) 
 
 
 
        radComboB = CType(editItem.FindControl("radComboB"), RadComboBox) 
 
        If radComboB Is Nothing = False Then 
            radComboB.ClearSelection() 
            radComboB.DataSource = getRecordByType(7, radComboA.SelectedValue, "", "", "", "", "") 
            radComboB.DataTextField = "modulename" 
            radComboB.DataValueField = "moduleid" 
            radComboB.DataBind() 
        
        End If 
 
 
    End Sub 




My coding work fine only when the RadGrid go into "Add Record " mode, no selection has been done on RadComboBox A, it fail to populate the data to RaCombobox B based on the first item in  RaCombobox A.
Does anyone has idea on populate the data in  RadComboBox B based on the first item in RadComboBox A  when RadGrid go into "Add Record" mode?
Shinu
Top achievements
Rank 2
 answered on 08 Apr 2010
3 answers
109 views

Hi,
I have a question regarding GridDropDownColumn

In a Grid, i want the field prodtype to be a dropdown, where i can pick a value from ANOTHER table, when i update
or insert in the grid.

I know i can do it like this, but in this example, the values come from the same table as the grid is build on:

<telerik:GridDropDownColumn
 DataSourceID="SqlDataSource1"
 ListTextField="prodtype" ListValueField="prodtype"
 UniqueName="prodtype" SortExpression="prodtype"
 HeaderText="prodtype" DataField="prodtype">
</telerik:GridDropDownColumn>

Hope i can do it without any code.

Br
Gert Petersen

Gert Petersen
Top achievements
Rank 1
 answered on 08 Apr 2010
1 answer
85 views
Hello, I have a grid and a checked listbox, what I want to do is filter de grid by selecting/deselecting the listbox items, i had it working, but I don't know why it stopped working, this is the code:

private void fncGridData(){  
        try 
        { 
            DataView dvDataView=new DataView(); 
            dvDataView = ((DataTable)Cache["Materials"]).DefaultView; 
            if (lstSubcategories.CheckedItems.Count == lstSubcategories.Items.Count) 
            { 
                dvDataView.RowFilter = ""
            } 
            else if(lstSubcategories.CheckedItems.Count==0){ 
                dvDataView.RowFilter = "id_sub_category=-1"
            } 
            else { 
                dvDataView.RowFilter = "id_sub_category IN (" + fncQueryComplement() + ")"
            } 
            RadGrid1.DataSource = (DataTable)Cache["Materials"]; 
        } 
        finally 
        {     
            SqlConnection.Close(); 
        } 
    } 

This code was exceuted on the ItemCheck property of the listbox, but then I made some changes to other parts of the code and it stopped working, why is this?

Regards.


Yavor
Telerik team
 answered on 08 Apr 2010
1 answer
118 views
I have looked at several posts in the forum regarding filtering.  I want to achieve the following objective:

  • On load if there is no filter value (populated from state) the filter row is hidden and the filter button in the command toolbar is toggled off
  • On load if there is a filter value (populated from state) the filter row is show and the filter button in the command toolbar is toggled on
  • If the filter button is toggled on, show the filter row (preferably on client-side rather than AJAX round trip)
  • If the filter button is toggled off, clear all filters, hide the filter row, and rebind the grid

I have been able to manage the display of the filter row using the ItemCreated event:
if (e.Item is GridFilteringItem && string.IsNullOrEmpty(Grid.MasterTableView.FilterExpression)) 
    e.Item.Display = false
else if (e.Item is GridCommandItem && !string.IsNullOrEmpty(Grid.MasterTableView.FilterExpression)) 
    var toolBar = e.Item.FindControl("ToolBar"as RadToolBar; 
    (toolBar.FindButtonByCommandName("Filter"as RadToolBarButton).Checked = true

On the client side it sort-of works, but there is some odd behavior:
function ToolBar_ClientButtonClicked(sender, args) 
    var button = args.get_item(); 
    switch (button.get_commandName()) 
    { 
        case 'Filter'
            if (button.get_isChecked()) 
            { 
                $find('<%= Grid.ClientID %>').get_masterTableView().showFilterItem(); 
            } 
            else 
            { 
                var masterTableView = $find("<%= Grid.ClientID %>").get_masterTableView(); 
                masterTableView.filter("Description""", Telerik.Web.UI.GridFilterFunction.NoFilter); 
                masterTableView.filter("Class""", Telerik.Web.UI.GridFilterFunction.NoFilter); 
                masterTableView.filter("DefaultCategory""", Telerik.Web.UI.GridFilterFunction.NoFilter); 
                masterTableView.hideFilterItem(); 
            } 
            break
    } 

I have to click the filter button three times to get it to show the row (turn on, turn off, turn on and then I see the row).  If I use jQuery to hide the .rgFilterRow class it works fine.

The calls to clear the filter appear to generate individual post-backs where I want one call to clear everything.  One thought was to use fireCommand and do the clean-up on the server side.  In either case I also want to only make the callback if the filter has a value in it (if the results aren't currently filtered there is no point in round tripping).

Thoughts?
Yavor
Telerik team
 answered on 08 Apr 2010
1 answer
127 views
Hello,

Scenario: User selected an item then scrolled the grid.

In order to find selected item fast, I would like to put a button that says "Bring into view" so the grid can show me the selected item.

1. Is there a way to do that ?
2. Is there a way to get the first / last visible item ?
Shinu
Top achievements
Rank 2
 answered on 08 Apr 2010
4 answers
160 views

Hi,

I need to create hierarchical rad grid programatically using DataTable, but I'm having a problem in settng the data source for level 1 hierarchy. When I try to expand the child table, an exception is thrown as
 
"Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand before 'Is' operator."

Kindly help me out regarding this issue. I have attached my code and exception trace. Thanks

Regards
Muhammad Farjad

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

<body>

 

     <form id="form1" runat="server">

 

         <telerik:RadScriptManager ID="RadScriptManager1" runat="server">

 

             <Scripts>

 

                 <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />

 

                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />

 

             </Scripts
        
</telerik:RadScriptManager>

 

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

         </telerik:RadAjaxManager>

 

        <div>

 

             <telerik:RadGrid ID="RadGrid1" runat="server" ondetailtabledatabind="RadGrid1_DetailTableDataBind">

 

              </telerik:RadGrid>

         </div>

 

    </form>

 </body>

---------------------------------------------------- Code Behind File ----------------------------------------------------------------------------

using
System;

 

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Configuration;

using System.Web.Security;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using Telerik.Web.UI;

 

public partial class Default : System.Web.UI.Page

    protected void Page_Load(object sender, EventArgs e) 
    {

         if (!IsPostBack)

         {

             //Add grand father table

             DataTable grandFatherTable = CreateDataTable("GrandFather");

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

             AddDataToTable("usman", "Usman", "Mansur", grandFatherTable);

             AddDataToTable("adnan", "Adnan", "Ahmad", grandFatherTable);

             AddDataToTable("nabeel", "Nabeel", "Ahmed", grandFatherTable);

 

              RadGrid1.DataSource = grandFatherTable;

              RadGrid1.MasterTableView.DataKeyNames = new string[] { "username" };

              RadGrid1.Width = Unit.Percentage(98);

              RadGrid1.PageSize = 5;

              RadGrid1.AllowPaging = true;

 

               //RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;

               RadGrid1.AutoGenerateColumns = false;

 

 

 

 

 

 

 

 

 

 

 

 

               RadGrid1.Skin = "Web20";

 

                RadGrid1.MasterTableView.PageSize = 15;

                RadGrid1.MasterTableView.Width = Unit.Percentage(100);

                GridBoundColumn boundColumn;

                boundColumn = new GridBoundColumn();

 

                RadGrid1.MasterTableView.Columns.Add(boundColumn);

                boundColumn.DataField = "username";

                 boundColumn.HeaderText = "User Name";

                 boundColumn = new GridBoundColumn();

 

                    RadGrid1.MasterTableView.Columns.Add(boundColumn);

                    boundColumn.DataField = "firstname";

                    boundColumn.HeaderText = "First Name";

                     boundColumn = new GridBoundColumn();

 

                    RadGrid1.MasterTableView.Columns.Add(boundColumn);

                    boundColumn.DataField = "lastname";

                    boundColumn.HeaderText = "Last Name";

 

                     //Add Father table

                     DataTable fatherTable = CreateDataTable("Father");

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                     AddDataToTable("usman", "u1", "u2", fatherTable);

                     AddDataToTable("adnan", "a1", "a2", fatherTable);

                     AddDataToTable("nabeel", "n1", "n2", fatherTable);

 

                    GridTableView tableViewFather = new GridTableView(RadGrid1);

                     tableViewFather.Width = Unit.Percentage(100);

                    tableViewFather.DataSource = fatherTable;

                    tableViewFather.DataKeyNames = new string[] { "username" };

 

                    GridRelationFields relationFields = new GridRelationFields();

                     relationFields.MasterKeyField = "username";

                     relationFields.DetailKeyField = "username";

 

                        tableViewFather.ParentTableRelation.Add(relationFields);

                        RadGrid1.MasterTableView.DetailTables.Add(tableViewFather);

                        boundColumn = new GridBoundColumn();

                        tableViewFather.Columns.Add(boundColumn);

                        boundColumn.DataField = "username";

                         boundColumn.HeaderText = "User Name";

 

                            boundColumn = new GridBoundColumn();

                             tableViewFather.Columns.Add(boundColumn);

                            boundColumn.DataField = "firstname";

                            boundColumn.HeaderText = "First Name";

                             
                            boundColumn = new GridBoundColumn();

                             tableViewFather.Columns.Add(boundColumn);

                            boundColumn.DataField = "lastname";

                             boundColumn.HeaderText ="Last Name";

        }
    }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    private DataTable CreateDataTable(string tableName)

     {   

            DataTable myDataTable = new DataTable(tableName);

             DataColumn myDataColumn;

             myDataColumn = new DataColumn();

             myDataColumn.DataType = Type.GetType("System.String");

 

            myDataColumn.ColumnName = "username";

 

            myDataTable.Columns.Add(myDataColumn);

            myDataColumn = new DataColumn();

            myDataColumn.DataType = Type.GetType("System.String");

             myDataColumn.ColumnName = "firstname";

             myDataTable.Columns.Add(myDataColumn);

            myDataColumn = new DataColumn();

             myDataColumn.DataType = Type.GetType("System.String");

             myDataColumn.ColumnName = "lastname";

             myDataTable.Columns.Add(myDataColumn);

             return myDataTable;

     }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    private void AddDataToTable(string username, string firstname, string lastname, DataTable myTable)

     {

        DataRow row;

        row = myTable.NewRow();

         //row["id"] = Guid.NewGuid().ToString();

         row["username"] = username;

 

 

 

 

         row["firstname"] = firstname;

         row["lastname"] = lastname;

         myTable.Rows.Add(row);

    }

 

 

 

 

 

 

 

    protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)

     {

        DataTable fatherTable = CreateDataTable("Father");

         AddDataToTable("usman", "u1", "u2", fatherTable);

         AddDataToTable("adnan", "a1", "a2", fatherTable);

         AddDataToTable("nabeel", "n1", "n2", fatherTable);

         e.DetailTableView.DataSource = fatherTable;

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

---------------------------------------------------------- exception ------------------------------------------------------------------------

Server Error in '/RadHierarchicalGrid' Application.
--------------------------------------------------------------------------------

Syntax error: Missing operand before 'Is' operator.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand before 'Is' operator.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:

[SyntaxErrorException: Syntax error: Missing operand before 'Is' operator.]
   System.Data.ExpressionParser.Parse() +4824040
   System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +121
   System.Data.DataView.set_RowFilter(String value) +153
   System.Data.LinqDataView.set_RowFilter(String value) +53
   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +375
   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +21
   Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray) +105
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +432
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +500
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   Telerik.Web.UI.GridTableView.PerformSelect() +4
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   Telerik.Web.UI.GridTableView.DataBind() +224
   Telerik.Web.UI.GridDataItem.OnExpand() +272
   Telerik.Web.UI.GridItem.set_Expanded(Boolean value) +109
   Telerik.Web.UI.GridExpandCommandEventArgs.ExecuteCommand(Object source) +34
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +134
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +115
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

Muhammad Farjad
Top achievements
Rank 1
 answered on 08 Apr 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?