Hi,
I'm facing a problem with ordering and filtering for Gridview control. For some reason '100' is considered smaller than 60 or 90. I think you can understand the problem better from the attached screenshot.
I'm facing a problem with ordering and filtering for Gridview control. For some reason '100' is considered smaller than 60 or 90. I think you can understand the problem better from the attached screenshot.
8 Answers, 1 is accepted
0
Hi Ejaz,
What is the type of the data - is it int or string? In case it is string, then all the values will be sorted as strings.
Regards,
Dimitrina
Telerik
What is the type of the data - is it int or string? In case it is string, then all the values will be sorted as strings.
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ejaz
Top achievements
Rank 1
answered on 06 Mar 2015, 12:01 PM
Hi Dimitrina,
The data is 'Double'. The itemssource is a DataTable.
Regards,
Ejaz
The data is 'Double'. The itemssource is a DataTable.
Regards,
Ejaz
0
Hi Ejaz,
RadGridView should sort the column depending on the bound data's type.
As a side note, in that case my recommendation would be to set RadGridView's ItemsSource to be the DataTable.DefaultView. Does this help?
In case not, is it possible for you to isolate the issue you experience in a demo project and send it to us in a new support ticket? You can also take a look at this blog post for a reference on how to isolate an issue.
Regards,
Dimitrina
Telerik
RadGridView should sort the column depending on the bound data's type.
As a side note, in that case my recommendation would be to set RadGridView's ItemsSource to be the DataTable.DefaultView. Does this help?
In case not, is it possible for you to isolate the issue you experience in a demo project and send it to us in a new support ticket? You can also take a look at this blog post for a reference on how to isolate an issue.
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ejaz
Top achievements
Rank 1
answered on 06 Mar 2015, 01:53 PM
Hi Dimitrina,
My license does not include dedicated support, but I would really like to get this problem fixed. I'm posting a sample code in which I've managed to replicated the issue, hope you can help me.
xaml
C#
Regards,
Ejaz
My license does not include dedicated support, but I would really like to get this problem fixed. I'm posting a sample code in which I've managed to replicated the issue, hope you can help me.
xaml
<
Grid
>
<
telerik:RadGridView
Name
=
"myGridView"
AutoGenerateColumns
=
"True"
/>
</
Grid
>
C#
class
Data
{
public
string
key;
public
string
value;
}
void
Main()
{
List<Data> data =
new
List<Data>();
data.Add(
new
Data() { key =
"one"
, value =
"0"
});
data.Add(
new
Data() { key =
"two"
, value =
"63.78"
});
data.Add(
new
Data() { key =
"three"
, value =
"100"
});
data.Add(
new
Data() { key =
"four"
, value =
"10"
});
DataTable dt =
new
DataTable();
dt.Columns.Add(
"key"
);
dt.Columns.Add(
"value"
);
foreach
(Data d
in
data)
{
List<
object
> ob =
new
List<
object
>();
ob.Add(d.key);
double
value;
if
(
double
.TryParse(d.value,
out
value))
ob.Add(value);
else
ob.Add(
null
);
dt.Rows.Add(ob.ToArray());
}
myGridView.ItemsSource = dt;
}
Regards,
Ejaz
0
Hi,
I tested the shared code and setting the DataTable.DefaultView as an ItemsSource seems to resolve the issue.
For example:
Let me know how this works for you.
Regards,
Dimitrina
Telerik
I tested the shared code and setting the DataTable.DefaultView as an ItemsSource seems to resolve the issue.
For example:
myGridView.ItemsSource = dt.DefaultView;
Let me know how this works for you.
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ejaz
Top achievements
Rank 1
answered on 09 Mar 2015, 01:54 PM
Hi Dimitrina,
As I mentioned earlier using DataTable.DefaultView did not fix the issue for me. Is there anything else you could suggest?
Regards,
Ejaz
As I mentioned earlier using DataTable.DefaultView did not fix the issue for me. Is there anything else you could suggest?
Regards,
Ejaz
0
Accepted
Hello Ejaz,
You are indeed right and I apologize for my confusion. After some further investigation, I can share the following information: checking the data presented in the DataTable, it is always of type string:
Regards,
Dimitrina
Telerik
You are indeed right and I apologize for my confusion. After some further investigation, I can share the following information: checking the data presented in the DataTable, it is always of type string:
dt.Rows.Add(ob.ToArray());You can set a break point after this line and check that the type of the Value is string. In that case, I am afraid RadGridView will sort it that way. You should either add an object Value or a double Value. In case of populating an object Value, you may need to explicitly set the DataType of the respective GridViewDataColumn.
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ejaz
Top achievements
Rank 1
answered on 12 Mar 2015, 06:47 AM
Hi Dimitrina,
I've found the solution to this issue thanks to you. It is like you said, we have to explicitly set the datatype, but not of the GridViewDataColumn but of the DataColumn in the DataTable.
Thanks for all your help.
Regards,
Ejaz
I've found the solution to this issue thanks to you. It is like you said, we have to explicitly set the datatype, but not of the GridViewDataColumn but of the DataColumn in the DataTable.
DataTable.Coulmns.Add(
"Value"
,
typeof
(
double
));
Thanks for all your help.
Regards,
Ejaz