Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
113 views

Hello.

I need help.

I need the coordinates of Column + Row of the selected cell in Radgrid.
Is the syntax of the source I attached correct?

please reply.

keep waiting for your reply

I want to communicate with client side and server side.


In Server Side(ASP.NET), 
<ClientSettings>
    <Selecting CellSelectionMode="MultiCell" />
    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    <ClientEvents OnCellSelected="cellSelected" />
</ClientSettings>

In JavaScript,
function cellSelected(sender, args)
{
            var selectedRow = args.get_row();
            var selectedColumn = args.get_column();
            var dataItem = args.get_gridDataItem();
            var tableView = args.get_tableView();
            var cellIndex = args.get_cellIndexHierarchical();
            var output = String.format("The selected cell is located in column with name: " + selectedColumn.get_uniqueName() + " and in row with index: " + dataItem.get_itemIndexHierarchical() + ". This cell has index " + cellIndex + " and it is part from " + tableView.get_name() + ".");

sender.get_masterTableView().fireCommand("cellSelected",    ????????????? );

}



Is the syntax of the source I attached correct?

To get the Selected Column&Row Coordinate

Client Side (aspx.cs)

protected void gv_ItemConmmand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "cellSelected")
    {
 var clickedColumnName = e.CommandArgument.ToString();

         // Label1.Text = clickedColumnName;
     }
 }

Do you have any other code from this source?

In Server Side

<ClientSettings>
    <Selecting CellSelectionMode="MultiCell" />
    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    <ClientEvents OnCellSelected="cellSelected" />
</ClientSettings>

In Client Side

protected voidRadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "CellClick")
    {
        var selectedColumn = e.Item.selectedColumn.get_uniqueName();
        var selectedRow = e.Item.get_row();
    }
}

Is the syntax of the source I attached correct?                     

anna
Top achievements
Rank 1
Bronze
Iron
 updated question on 31 Jan 2022
0 answers
116 views

I have hierarchal data with thousands of nodes.  I am using a RadTreeView control with "Load On Demand" mode, with Expand mode set to "ServerSideCallback".  I set up the handler. It creates the child nodes, grabs about 10 custom fields and adds them to the "Attributes" collection, and adds the nodes to e.Node.Nodes collection.  All of this is working great, but I want to display values from the Attributes collection.

How do I access those attributes from the NodeTemplate? 

The node template seems to work, but it is not showing the fields. I assume this is because I am just adding the nodes and do not call "DataBind"?

Thanks.

Mike
Top achievements
Rank 1
 asked on 30 Jan 2022
0 answers
147 views

hi

I have 4 table hierarchies in Radgrid.

to fill out  "SqlDataSource_Third"
Table "Third_Table"
Need to access "DataKeyNames" All Parent tables including access to:

"Master_ID" from "Mater_Table" table
"First_ID" from table "First_Table"
"Second_ID" from the "Second_Table" table

I Need "DataKeyNames" All Parent tables In the event:

"RadGrid1_DetailTableDataBind"
Do I have access?

 

 


        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource_Master" AutoGenerateColumns="False" OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
            <MasterTableView DataSourceID="SqlDataSource_Master" Name="Master_Table" DataKeyNames="Master_ID">
                <DetailTables>
                    <telerik:GridTableView runat="server" Name="First_Table" DataKeyNames="First_ID" DataSourceID="SqlDataSource_First">
                        <DetailTables>
                            <telerik:GridTableView runat="server" Name="Second_Table" DataKeyNames="Second_ID" DataSourceID="SqlDataSource_Second">
                                <DetailTables>
                                    <telerik:GridTableView runat="server" Name="Third_Table" DataKeyNames="Third_ID" DataSourceID="SqlDataSource_Third">
                                        <Columns>
                                            <telerik:GridBoundColumn UniqueName="column_Third">
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                    </telerik:GridTableView>
                                </DetailTables>
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="column_Second">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                        <Columns>
                            <telerik:GridBoundColumn UniqueName="column_First">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridBoundColumn UniqueName="column_Master">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>



        <asp:SqlDataSource ID="SqlDataSource_Third" runat="server">
            <SelectParameters>
                <asp:Parameter Name="Master_ID" Type="Int32" />
                <asp:Parameter Name="First_ID" Type="Int32" />
                <asp:Parameter Name="Second_ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>


 


        protected void RadGrid1_DetailTableDataBind(object sender, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            if (e.DetailTableView.Name == "Third_Table")
            {
                GridTableView detailtabl1 = (GridTableView)e.DetailTableView;
                GridDataItem Third_parentItem = (GridDataItem)detailtabl1.ParentItem;


                SqlDataSource_Third.SelectParameters["Second_ID"].DefaultValue = Third_parentItem.GetDataKeyValue("Second_ID").ToString();

                SqlDataSource_Third.SelectParameters["Master_ID"].DefaultValue = ?

                SqlDataSource_Third.SelectParameters["First_ID"].DefaultValue = ?


            }
        }

Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
 updated question on 30 Jan 2022
0 answers
102 views

Attached File : WebApplication14.zip , RadListBox.png

I will convert the attached file to RadListBox.

You need to add 2 Labels to the RadListBox in the attached file.

Conversion condition requires adding 2 Labels to RadListBox.

Attached files(WebApplication14.zip) must be converted like attached files(RadListBox.png).

 

 

Please Help me.

anna
Top achievements
Rank 1
Bronze
Iron
 asked on 30 Jan 2022
0 answers
106 views

Attached File : RadListBox.png

ASP.NET, RadListBox, Web

Question-1) ItemTemplate of RadListBox, By applying multi-label, Is it possible to implement multi-column of ListBox?

Question-2) If Question-1 is possible, As in the attached file, After creating one more RadListBox, Is it possible to move data between listboxes?

Question-3) If Question-2 is possible, like the source below,Listbox.Item.Add(item),  Listbox.Item.Insert(index),  Listbox.SelectedItemindex, Listbox.Selected.Items.Count   

Can you code using functions?

private void AddRemoveAll(ListBox aSource, ListBox aTarget)
 {
  try
  {
   foreach(ListItem item in aSource.Items)
   aTarget.Items.Add(item);
   aSource.Items.Clear();
  }
  catch(Exception expException)
  {
    Response.Write(expException.Message);
  }
 }
private void private void MoveUp(ListBox lstBox)
 { 
  int   iIndex, iCount, iOffset, iInsertAt,iIndexSelectedMarker = -1;
  string lItemData,lItemval;

  try
   {
  // Get the count of items in the list control
  iCount = lstBox.Items.Count;
       
  // Set the base loop index and the increment/decrement value based
  // on the direction the item are being moved (up or down).
  iIndex = 0;
  iOffset = -1;
  // Loop through all of the items in the list.
  while(iIndex < iCount) 
   {
    // Check if this item is selected.
    if(lstBox.SelectedIndex > 0)
    {
    // Get the item data for this item
     lItemval =lstBox.SelectedItem.Value.ToString();
    lItemData = lstBox.SelectedItem.Text.ToString() ;
    iIndexSelectedMarker=lstBox.SelectedIndex; 
      
    // Don't move selected items past other selected items
       if(-1 != iIndexSelectedMarker)
       {
         for(int iIndex2 = 0; iIndex2 < iCount; ++iIndex2)
      {
        // Find the index of this item in enabled list
            if(lItemval == lstBox.Items[iIndex2].Value.ToString())
         {
           
          // Remove the item from its current position
             lstBox.Items.RemoveAt(iIndex2);  
             
      // Reinsert the item in the array one space higher 
             // than its previous position
             iInsertAt=(iIndex2 + iOffset)<0?0:iIndex2+iOffset;
             ListItem li= new ListItem(lItemData,lItemval);
          lstBox.Items.Insert(iInsertAt,li);
          break;
         }
        }
        }
     }
            
     // If this item wasn't selected save the index so we can check
        // it later so we don't move past the any selected items.
        else if(-1 == iIndexSelectedMarker)
        {
         iIndexSelectedMarker = iIndex;  
       break;
     }
      iIndex = iIndex + 1;
    }
    if(iIndexSelectedMarker==0)
      lstBox.SelectedIndex=iIndexSelectedMarker;
    else
      lstBox.SelectedIndex=iIndexSelectedMarker-1;
   }
   catch(Exception expException)
   {
    Response.Write(expException.Message); 
   } 
 } 

 

An example source for reference please.

Your answer is desperately needed.

I will keep waiting for your reply.
anna
Top achievements
Rank 1
Bronze
Iron
 updated question on 30 Jan 2022
0 answers
93 views

Is there any way to sort nodes based on hierarchyid?

currently default sorting based on alphabetical order.

 

Thanks in advance

Hari
Top achievements
Rank 1
 asked on 28 Jan 2022
0 answers
95 views

Hello,

I have a form to show/update Staff information. There is a  RadComboBox (CheckBoxes =True,  DataSourceID = "sds_multiSites", DataTextField = "Site", DataValueField = "idSite"), that Iist all the Sites in our organization.

When the form loads, I read a table where I find the Staff-MultiSitesSelected. I read all the Sites where the staff works and I check this sites in the RadComboBox. I sort the RadComboBox by the TextValue, using rcb_multiSites.SortItems(New SortCheckedComboItemsFirst()), and this function let me keep the checked items at the top of the list.

Problem: When updating the combo selection, unchecking some items (that are at the top) and selecting new items. After the refresh, the new checked items are wrong even if I don't sort again. The selected index is wrong because is counting the old-checked items that were at the top.

 Any suggestions?

cc

ASP.NET

<telerik:RadComboBox ID="rcb_multiSites" Runat="server" DataSourceID="sds_multiSites" DataTextField="Site" DataValueField="idSite"    CheckBoxes = "True" EnableCheckAllItemsCheckBox = "true" AutoPostBack = "false" ></telerik:RadComboBox>          

VB.NET read the selection from a table and check the selected items in the combo

  Private Sub create_new_employee_SaveStateComplete(sender As Object, e As EventArgs) Handles Me.SaveStateComplete
        Dim i As Integer ' event launched after load form

        If Not IsPostBack Then
            Dim conn3 As String = DirectCast(ConfigurationManager.ConnectionStrings("HR_ConnStr").ConnectionString, String)
            Dim queryStr3 As String = "SELECT * FROM StaffSites WHERE IDPerson = @IDPerson ORDER BY Name"

            Using myConnection3 As New SqlConnection(conn3)
                Dim myCommand3 As New SqlCommand(queryStr, myConnection3)
                myConnection3.Open()
                myCommand3.Parameters.AddWithValue("@IDPDSProfilesPerson", IDPDSProfilesEmployee)
                Dim MyReader3 As SqlDataReader = myCommand3.ExecuteReader

                If MyReader3.HasRows Then
                    While (MyReader3.Read())
                        Dim idSite As String = MyReader3("IDSite")
                        Dim indexItem As Integer =  rcb_multiSites.FindItemIndexByValue(idSite)
                        rcb_multiSites.Items(indexItem).Checked = True
                    End While
                    rcb_multiSites.Sort = RadComboBoxSort.Ascending
                    rcb_multiSites.SortItems(New SortCheckedComboItemsFirst())
                    rcb_multiSites.AllowCustomText = True
                End If
            End Using
        End If
    End Sub

This function sort the list and keeps the checked Items at the top. The function is from a sample in this website

VB.NET

   Public Class SortCheckedComboItemsFirst
        Implements IComparer
        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            Dim p1 As New RadComboBoxItem()
            Dim p2 As New RadComboBoxItem()

            If TypeOf x Is RadComboBoxItem Then
                p1 = TryCast(x, RadComboBoxItem)
            Else
                Throw New ArgumentException("Object is not of type RadComboBoxItem.")
            End If

            If TypeOf y Is RadComboBoxItem Then
                p2 = TryCast(y, RadComboBoxItem)
            Else
                Throw New ArgumentException("Object is not of type RadComboBoxItem.")
            End If

            Dim cmp As Integer = 0

            If p1.Checked Then

                If p2.Checked = False Then
                    Return -1
                    'uncomment for skipping the sorting of the checked items
                    'Else 'this line
                    ' Return 1 'this line
                End If
            ElseIf p2.Checked Then
                Return 1
            End If

            If p1.ComboBoxParent.Sort = RadComboBoxSort.Ascending Then
                'here we compare the Values of the items
                'cmp = [String].Compare(p1.Value, p2.Value, Not p1.ComboBoxParent.SortCaseSensitive)
                cmp = [String].Compare(p1.Text, p2.Text, Not p1.ComboBoxParent.SortCaseSensitive)
            End If
            If p1.ComboBoxParent.Sort = RadComboBoxSort.Descending Then
                'here we compare the Values of the items
                'cmp = [String].Compare(p1.Value, p2.Value, Not p1.ComboBoxParent.SortCaseSensitive) * -1
                cmp = [String].Compare(p1.Text, p2.Text, Not p1.ComboBoxParent.SortCaseSensitive) * -1
            End If
            Return cmp
        End Function
M
Top achievements
Rank 2
 updated question on 27 Jan 2022
1 answer
135 views

Hi,

My main thread is  "Check All" feature is not working as expected with Load On Demand

As there is limitation on LoadOnDemand feature in RadComboBox control, as a workaround I used RadMultiSelect with Virtualization.

But when I add the below line it showing console error.

<VirtualSettings ItemHeight="26" ValueMapper="valueMapper" />

As you requested in main thread I am attaching current implementation to investigate the problem. 

Attaching relevant files for your reference since full project can't upload due to max size exceed.

Highly appreciate your quick response.

Thanks

Chandi

 

 

Attila Antal
Telerik team
 answered on 27 Jan 2022
1 answer
150 views

My team is using Telerik.UI.for.AspNet.Ajax.Net45 v 2020.3.1021. Due to having some clients on unsupported browsers, we need to redirect them to an older page that is compatible for them.

Do you offer any built-in functionality to determine if a Telerik control on a page is supported in the user's browser?

Vessy
Telerik team
 answered on 26 Jan 2022
1 answer
84 views

Regardless of browser, when you zoom out to text size 80% or less the text in the RadPanelBar disappears. 

Is there a way to make the text visible regardless of the zoom level?

/POE

Vessy
Telerik team
 answered on 26 Jan 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?