Telerik Forums
UI for ASP.NET AJAX Forum
7 answers
281 views
Hi,

I have problem with ajax postback. Is possible to cancel ajax postback after refresh grid.

I have grid and I use this code:
function RefreshGrid(search) {
  if (search != "") {
    document.getElementById("search").value = search;
    var masterTable = $find("<%= grdResult.ClientID %>").get_masterTableView();
    masterTable.rebind();
  }
}
 
function requestStart(sender, eventArgs) {
     document.getElementById("ajaxrequest").value = "true";
}
function responseEnd(sender, eventArgs) {
    document.getElementById("ajaxrequest").value = "false";
}

But problem is, that I refresh grid, all page codebehind are called. Not only webservice (use it for reading data).
In PageLoad I use
sAjaxRequest = Request.Params["ajaxrequest"] + "";
if (sAjaxRequest != "true")
{
     //... loading controls and set property from DB (radcombo, radgrid, ...)
}

Grid
<telerik:RadGrid ID="grdResult" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None" onitemdatabound="grdResult_ItemDataBound" PageSize="20" Width="100%" DataSourceID="GridDataSource" BorderStyle="None">
 <PagerStyle Mode="NextPrevAndNumeric" PageButtonCount="10" />
   <ClientSettings AllowDragToGroup="True" EnableRowHoverStyle="true">
   <DataBinding EnableCaching="true" />
   <Selecting AllowRowSelect="true" />
   <ClientEvents /></ClientSettings>
   <HeaderContextMenu enableautoscroll="True"></HeaderContextMenu>
   <MasterTableView>
      <Columns>
         <telerik:GridBoundColumn DataField="Manufacturer" HeaderText="Manufacturer" UniqueName="colManufacturer"></telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Stock" DataFormatString="{0:0}" HeaderStyle-HorizontalAlign="Right" HeaderText="Stock" ItemStyle-HorizontalAlign="Right" UniqueName="Stock"></telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="Price" HeaderStyle-HorizontalAlign="Right" HeaderText="Price" ItemStyle-HorizontalAlign="Right" UniqueName="Price"></telerik:GridBoundColumn>
        </Columns>
      </MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="GridDataSource" runat="server" SelectMethod="FillResultGrid" TypeName="shop.Service">
  <SelectParameters>
    <asp:FormParameter FormField="search" Name="sSearch" Type="String" />
  </SelectParameters>
</asp:ObjectDataSource>

Problem is, that I don't set combos data and property, then I receive blank controls after ajax.
Ajax framework set my controls, but I don't want it.

Thanks for answer.
Roman Krsko
Iana Tsolova
Telerik team
 answered on 24 Sep 2010
1 answer
345 views
Hi 

I've taken an example from the demo's site, to hide the expand button and add it into an existing column alongside the text.
using this code which is run from RadGrid1_ItemDataBound

public void CreateExpandCollapseButton(GridItem item, string columnUniqueName, String ButtonColumn)
        {
            if (item is GridDataItem)
            {
                if (item.FindControl("MyExpandCollapseButton") == null)
                {
                    Button button = new Button();
                    button.Click += new EventHandler(button_Click);
                    button.CommandName = "ExpandCollapse";
                    button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand";
                    button.ID = "MyExpandCollapseButton";
 
                    if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client)
                    {
                        string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID);
 
                        button.OnClientClick = script;
                    }
 
                    int level = item.ItemIndexHierarchical.Split(':').Length;
                    if (level > 1)
                    {
                        button.Style["margin-left"] = level * 5 + "px";
                    }
 
                    TableCell cell = ((GridDataItem)item)[ButtonColumn];
                    cell.Controls.Add(button);
                    cell.Controls.Add(new LiteralControl(" "));
                    cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(ButtonColumn).ToString()));
                }
            }
        }

But this code was for the selfHierarchy demo.  I have 6 inner details tables each within each other like so

<telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" OnItemDataBound="RadGrid1_ItemDataBound" ShowStatusBar="true" Skin="Office2007" OnItemCreated="RadGrid1_ItemCreated"
            runat="server" AutoGenerateColumns="true" AllowSorting="true" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowSelection="False" OnColumnCreated="RadGrid1_ColumnCreated"
            AllowPaging="false" GridLines="None">
            <MasterTableView DataKeyNames="HierarchyID, Link, Name" AllowMultiColumnSorting="True" AutoGenerateColumns="true" HorizontalAlign="Right">
            <DetailTables>
            <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="2" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right">
            <ParentTableRelation>
                 <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" />
            </ParentTableRelation>
            <DetailTables>
                <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="3" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" />
                    </ParentTableRelation>
                    <DetailTables>
                    <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="4" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" />
                        </ParentTableRelation>
                        <DetailTables>
                        <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="5" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right">
                            <ParentTableRelation>
                                <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" />
                            </ParentTableRelation>
                            <DetailTables>
                            <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="6" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" />
                                </ParentTableRelation>
                            </telerik:GridTableView>
                            </DetailTables>
                        </telerik:GridTableView>
                        </DetailTables>
                    </telerik:GridTableView>
                    </DetailTables>
                </telerik:GridTableView>
                </DetailTables>
            </telerik:GridTableView>
            </DetailTables>
        </MasterTableView>
        </telerik:RadGrid>

So  i need to know how i can rewrite the CreateExpandCollapseButton for the detailtables and how to hide the default expand column within the details table.
Assuming something like this

            if (e.Column is GridExpandColumn)
            {
                e.Column.Visible = false;
            }

Thanks for any assistance.

Matt
Pavlina
Telerik team
 answered on 24 Sep 2010
1 answer
73 views
hi
i work with 1,000,000 records of data!
how can i use RadGrid with sql2005 paging? (that every page = 1000 rows)
with paging , sorting , grouping and export current page to excel...
please help me!
really thanks :)
Tsvetina
Telerik team
 answered on 24 Sep 2010
1 answer
68 views
Dear Telerik Team,

We were evaluating telerik ajax for one our major project.

We want a feature such as Maintaining the state of some additional Key-Value collection for the whole life cycle of the Ajax Panel or AjaxManager.

We are in a requirement of loading UserControls dynamically in the page where as we will be in requirement of storing the values from the UserControl some where which should not be in ViewState or should not be burden for page loading (performance on loading the page).

And also we should be able to read this key-value collection from the client side & server side.

Is there any supporting feature available in the Telerik Ajax. Please guide in this regard.

Thanks,

Suneetha.
Maria Ilieva
Telerik team
 answered on 24 Sep 2010
1 answer
86 views
Hi,

I'm using RadControls for ASP.NET AJAX Q1 2010 with C# (Visual Studio 2008, EPi-Server)
and have some problems with skinning.

I've copied skins from their installed folder of C:\...\RadControls for ASP.NET AJAX Q1 2010\Skins\...
and given them new names in my C# solution - Grid.ProductShortList.css, etc. I've added the accompanying
folders on the same level as the CSS-files, and of course altered the names of the classes, etc. inside the CSS-files.

The CSS-files are referenced either by a masterpage, or in some cases by the page itself.

Since the RadChart only has a "common" CSS, I've used this, and renamed the copy Chart.KraftinorEpi.css.

The problem is that some of the charts that use this skin works, but others don't.
The ones that don't work get a dark gray background (#525252) - sort of a negative/inverted look.

The attached image shows two radcharts (black bars are just censored information),
both existing in the same .ascx file. Both are set to Skin="KraftinorEpi" EnableEmbeddedSkins="false".
The lower chart has the correct look, but the upper chart displays the weird "inverse" look.

Any ideas what the reason for this can be?
Evgenia
Telerik team
 answered on 24 Sep 2010
0 answers
60 views
Hello,

I want ask, if is possible use other means of fill data as list of objects? For example DataSet or XML for Client-side databinding. Can I generate XML and then transform to necessary structure for RadGrid?

Both two samples (Client-side databinding) are only with list of objects, but I need something dynamically (XML, DataSet), not objects with defined structure.

Thanks.

Roman Krsko
Roman Krsko
Top achievements
Rank 1
 asked on 24 Sep 2010
1 answer
168 views
Is there an easy way to alternate the color of each 'row' in a listbox, like you can in a grid?  maybe i'm just tired, and missing it.  are there examples out there?

Shinu
Top achievements
Rank 2
 answered on 24 Sep 2010
1 answer
248 views
Hi,

I am trying to invoke a javascript function on the Pageload event and get the object of the comboox in that function. But the $find returns me a null. 
Here is my page load method in .cs file

protected void Page_Load(object sender, EventArgs e)
{
Telerik.Web.UI.RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("SaveOriginalValues();");
}

This is my javascript function
function SaveOriginalValues()
    {
       var cmb1 = $find('<%= cmb1.ClientID %>');
       var selectedItem = cmbHealthPlan.get_selectedItem();
       
    }

 cmb1 has a null value when I execute this. 
Could anyone please help? 

Thanks & Regards,
Ketaki


Shinu
Top achievements
Rank 2
 answered on 24 Sep 2010
3 answers
1.1K+ views

We had an issue with the radconfirm popup which has to open on the click of delete image button which is present in the Telerik Radgrid template column.

Scenario:

Usually we call a callback function   and get the argument(Yes/NO) which user has selected.

In the call back function we used to get the reference of the button and then do a post back.

We tried the same approach here also, but since the Image button is inside the template column we are unable to get the reference in Javascript.

Question:

How to get the control id of a Image button which is present in a Telerik RadGrid in Javascript ?

Can you please help us on this
Princy
Top achievements
Rank 2
 answered on 24 Sep 2010
1 answer
119 views

aspx code

       <asp:Panel ID="TrendPanel" runat="server" Enabled="True">
           <telerik:radchart ID = "RadChart1" runat="server" Height = "780px" Width = "950px" Skin="Vista" >
             <Appearance Corners="Round, Round, Round, Round, 7">
                 <FillStyle FillType="ComplexGradient">
                     <FillSettings>
                         <ComplexGradient>
                             <telerik:GradientElement Color="243, 253, 255" />
                             <telerik:GradientElement Color="White" Position="0.5" />
                             <telerik:GradientElement Color="243, 253, 255" Position="1" />
                         </ComplexGradient>
                     </FillSettings>
                 </FillStyle>
                 <Border Color="212, 221, 222" />
             </Appearance>
</telerik:radchart>

c# code

private void UpdateRadChart(wchart wc)
  {
  
      string d1 = wc.d1.ToString("yyyy/MM/dd").Replace(".", "/");
      string d2 = wc.d2.ToString("yyyy/MM/dd").Replace(".", "/");
  
      TrendPanel.Visible = true;
      RadChart1.Visible = true;
  
      RadChart1.Series.Clear();
  
  
      RadChart1.Series.ClearItems();
  
      RadChart1.PlotArea.XAxis.Items.Clear();
      RadChart1.PlotArea.YAxis.Items.Clear();
      RadChart1.PlotArea.YAxis.ScaleBreaks.Segments.Clear();
  
  
  
      RadChart1.PlotArea.YAxis.ScaleBreaks.Enabled = false;
      RadChart1.PlotArea.YAxis.AutoScale = true;
      RadChart1.PlotArea.XAxis.AutoScale = true;
  
  
      RadChart1.PlotArea.YAxis.Appearance.LabelAppearance.Visible = true;
      RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.AutoSize = false;
  
      RadChart1.AutoLayout = false;
      RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Height = Telerik.Charting.Styles.Unit.Pixel(15);
      RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Width = Telerik.Charting.Styles.Unit.Pixel(150);
      RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = AlignedPositions.Top;
        
        
      string type = wc.type;
        
  
      string sqlString = null;
      SqlConnection Conn = GetSqlConnection();
  
      if (type == "oil")
      {
          if (wc.well == 0) return;    
          sqlString = @"exec dbo.rwell " + "'" + d1 + "', '" + d2 + "', " + wc.well + ", 0";
  
          SqlDataAdapter adapter = new SqlDataAdapter(sqlString, Conn);
          DataSet ds = new DataSet();
          adapter.Fill(ds);
          ChartSeries currentSeries = null;
          currentSeries = RadChart1.CreateSeries("нефть, м3", Color.Empty, Color.Empty, ChartSeriesType.SplineArea);
          currentSeries.Appearance.Border.Color = Color.Black;
          currentSeries.Appearance.ShowLabels = false;
          currentSeries.Appearance.FillStyle.MainColor = Color.SaddleBrown;
          currentSeries.Appearance.FillStyle.SecondColor = Color.Black;
  
  
          RadChart1.ChartTitle.TextBlock.Text = "Тренд по результатам промежуточных замеров по скважине №" + wc.well.ToString();
          ChartAxisItem xAxis = new ChartAxisItem();
          RadChart1.PlotArea.XAxis.IsZeroBased = false;
          RadChart1.PlotArea.XAxis.AutoScale = false;
          RadChart1.PlotArea.XAxis.Appearance.CustomFormat = "dd.MM HH:mm";
          //RadChart1.PlotArea.XAxis.Appearance.MajorTick.Width = 90;
          RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
          RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 90;
          RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;
  
          foreach (DataRow dbRow in ds.Tables[0].Rows)
          {
  
              DateTime scDate = new DateTime();
              scDate = Convert.ToDateTime(dbRow["e"]);
              ChartAxisItem item = new ChartAxisItem();
              item.Value = (decimal)scDate.ToOADate();
              RadChart1.PlotArea.XAxis.AddItem(item);
  
              if (currentSeries != null)
              {
                  currentSeries.AddItem((double)dbRow["o"]);
              }
                
          }
  
          Conn.Close();
  
      }
      else if (type == "padu")
      {
          sqlString = @"exec dbo.cpadu " + "'" + d1 + "', '" + d2 + "', " + wc.bush + ", 0";
  
          SqlDataAdapter adapter = new SqlDataAdapter(sqlString, Conn);
          DataSet ds = new DataSet();
          adapter.Fill(ds);
  
          RadChart1.ChartTitle.TextBlock.Text = "Состояние ПАДУ по скважинам куста №" + wc.bush.ToString();
          ChartAxisItem xAxis = new ChartAxisItem();
            
          RadChart1.PlotArea.XAxis.IsZeroBased = false;
          RadChart1.PlotArea.XAxis.AutoScale = false;
          RadChart1.PlotArea.XAxis.Appearance.CustomFormat = "dd.MM HH:mm";
          RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
          RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 90;
          RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;
            
  
          int w = 0;
          int v = 0;
          ChartSeries currentSeries = null;
  
            
          RadChart1.PlotArea.YAxis.Appearance.LabelAppearance.Visible = false;
          RadChart1.PlotArea.YAxis.AutoScale = false; // это нужно чтобы вручную установить шкалу
  
  
          ChartAxisItem itemlast = null;
          int maxr = 0;
  
          foreach (DataRow dbRow in ds.Tables[0].Rows)
          {
  
              w = Convert.ToInt32(dbRow["w"]);
              v = Convert.ToInt32(dbRow["v"]);
              if (maxr < Convert.ToInt32(dbRow["r"]))
                  maxr = Convert.ToInt32(dbRow["r"]);
              DateTime scDate = new DateTime();
              scDate = Convert.ToDateTime(dbRow["t"]);
              ChartAxisItem item = new ChartAxisItem();
              item.Value = (decimal)scDate.ToOADate();
  
              if (itemlast == null)
                  RadChart1.PlotArea.XAxis.AddItem(item);
              else if (itemlast.Value != item.Value)
                 RadChart1.PlotArea.XAxis.AddItem(item);
  
  
              ChartSeriesItem itm = new ChartSeriesItem();
              itm.XValue = scDate.ToOADate();
  
  
              currentSeries = RadChart1.GetSeries(w.ToString()); // пытаемся найти серию по скважине, если не нашлась - создаем новую
              if (currentSeries == null)
              {
                  currentSeries = RadChart1.CreateSeries(w.ToString(), Color.Empty, Color.Empty, ChartSeriesType.Line);
                  currentSeries.Appearance.LineSeriesAppearance.Width = 3;
  
  
              }
              ChartSeriesItem im = null; // фиктивная точка для рисования лесенок
              if (currentSeries != null)
              {
                  if (v > 0)
                  {
                      if (v < 2) // для граничной фиктивной точки 0 устанавливать не нужно, если ПАДУ для скважины до этого была в работе
                      {
                          im = new ChartSeriesItem();
                          im.XValue = scDate.ToOADate();
                          im.YValue = 0;
                          currentSeries.Items.Add(im);
                      }
                      itm.YValue = double.Parse(dbRow["r"].ToString());
                  }
                  else
                  {
                      if (v == 0)
                      {
                          im = new ChartSeriesItem();
                          im.XValue = scDate.ToOADate();
                          im.YValue = double.Parse(dbRow["r"].ToString());
                          currentSeries.Items.Add(im);
                      }
                      itm.YValue = 0;
                  }
  
  
                  currentSeries.Items.Add(itm);
  
                  currentSeries.DefaultLabelValue = String.Empty;
  
  
              }
  
  
              itemlast = item;
  
          }
  
          RadChart1.PlotArea.YAxis.AddRange(0, maxr, 1); 
    
          Conn.Close();
  
      }

And this is result into attach.

Why this code doesn't work for my case? Why time stamps are cut?
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Height = Telerik.Charting.Styles.Unit.Pixel(15); 
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Width = Telerik.Charting.Styles.Unit.Pixel(150); 

Evgenia
Telerik team
 answered on 24 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?