Hello Friends,
I used new radgrid with dynamic column with custom pagging.
In my list display column which contain Int, Datetime value.I also applied filtering on all the textbox.
I check validation on server side , radgrid ItemCommand Event.
When some one will enter text on Int column than i will display Error message using the radalert on server side.
after message is displyed i need to blank on filter textbox.
How i will do blank filtered textbox?
i have tried below code but its not working.
dg.MasterTableView.FilterExpression = String.Empty
Thanks & Regards
Jignesh Patel
I used new radgrid with dynamic column with custom pagging.
In my list display column which contain Int, Datetime value.I also applied filtering on all the textbox.
I check validation on server side , radgrid ItemCommand Event.
When some one will enter text on Int column than i will display Error message using the radalert on server side.
after message is displyed i need to blank on filter textbox.
How i will do blank filtered textbox?
i have tried below code but its not working.
dg.MasterTableView.FilterExpression = String.Empty
Thanks & Regards
Jignesh Patel
6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 10 May 2010, 02:09 PM
Hi Jignesh,
Try the following code snippet in order to clear the filters as described in the Demo.
Regards,
Princy.
Try the following code snippet in order to clear the filters as described in the Demo.
foreach (GridColumn column in RadGrid1.MasterTableView.Columns) |
{ |
column.CurrentFilterFunction = GridKnownFunction.NoFilter; |
column.CurrentFilterValue = string.Empty; |
} |
RadGrid1.MasterTableView.FilterExpression = string.Empty; |
RadGrid1.MasterTableView.Rebind(); |
Regards,
Princy.
0

Jignesh
Top achievements
Rank 1
answered on 11 May 2010, 06:26 AM
Thanks Princy,
For quick reply.
I had tried it but its not working.
My requirement is suppose we will display 5 column in grid.
(1) Id : int
(2) Created Date : DateTime
(3) Name : Varchar
(4) Expiration Date : DateTime
(5) Address : Varchar
suppose user will enter int value on Id column and apply filter than record will be diplay as per filteration. now again user will enter text into Created Date column an apply filter than i need to saw message in rad alert "Enter valid date". and blank text on Filter Created Date column, also Id filter column text should be as it is.
I need error message on ItemCommand Event.
Thanks & Regards
Jignesh Patel
For quick reply.
I had tried it but its not working.
My requirement is suppose we will display 5 column in grid.
(1) Id : int
(2) Created Date : DateTime
(3) Name : Varchar
(4) Expiration Date : DateTime
(5) Address : Varchar
suppose user will enter int value on Id column and apply filter than record will be diplay as per filteration. now again user will enter text into Created Date column an apply filter than i need to saw message in rad alert "Enter valid date". and blank text on Filter Created Date column, also Id filter column text should be as it is.
I need error message on ItemCommand Event.
Thanks & Regards
Jignesh Patel
0

Shinu
Top achievements
Rank 2
answered on 14 May 2010, 12:17 PM
Hello Jignesh,
One suggestion to achieve this functionality is by accessing the DatePicker in FilterItem and attaching the 'OnError' client event to show radalert. Check out the following code and see whether it helps you.
C#:
Java Script:
Regards,
Shinu.
One suggestion to achieve this functionality is by accessing the DatePicker in FilterItem and attaching the 'OnError' client event to show radalert. Check out the following code and see whether it helps you.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridFilteringItem) |
{ |
RadDatePicker pick = new RadDatePicker(); |
GridFilteringItem filteritem = (GridFilteringItem)e.Item; |
RadDatePicker dtpick = (RadDatePicker)filteritem["CreatedDate"].Controls[0]; |
dtpick.DateInput.ClientEvents.OnError = "OnError"; |
} |
} |
Java Script:
<script type="text/javascript"> |
function OnError(sender, args) |
{ |
radalert("Enter valid date"); |
var dtpicker = sender; |
dtpicker.clear(); |
} |
</script> |
Regards,
Shinu.
0

Jignesh
Top achievements
Rank 1
answered on 19 May 2010, 10:44 AM
Hello Shinu
Thanks for your help.
But i need a solution like when i enter the text value in Id (Datatype : int ) column than it gives rad alert message "Enter numeric value" at a time that text value in column should be blank.
So how i will do for blank a value in column when i enter wrong value in a column?
Please help me.
Thanks & Regards
Jignesh Patel
Thanks for your help.
But i need a solution like when i enter the text value in Id (Datatype : int ) column than it gives rad alert message "Enter numeric value" at a time that text value in column should be blank.
So how i will do for blank a value in column when i enter wrong value in a column?
Please help me.
Thanks & Regards
Jignesh Patel
0

Shinu
Top achievements
Rank 2
answered on 19 May 2010, 12:31 PM
Hello Jignesh,
You can access the textbox in filteritem and attach the OnKeyPress event to check whether typed a letter or not, and if so cancel the event and show an alert as shown below.
C#:
Java Script:
Regards,
Shinu.
You can access the textbox in filteritem and attach the OnKeyPress event to check whether typed a letter or not, and if so cancel the event and show an alert as shown below.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridFilteringItem) |
{ |
GridFilteringItem filteritem = (GridFilteringItem)e.Item; |
TextBox textbox = (TextBox)filteritem["ID"].Controls[0]; |
textbox.Attributes.Add("onkeypress","checkChar(this, event)"); |
} |
} |
Java Script:
<script type="text/javascript"> |
function checkChar(textbox, e) { |
if ((e.keyCode >= 97 && e.keyCode <= 122) || (e.keyCode >= 65 && e.keyCode <= 90)) { |
radalert("Enter numeric value"); |
e.cancel = true; |
try { |
e.returnValue = false; |
e.cancelBubble = true; |
if (document.all) { //IE |
e.keyCode = 0; |
} |
else { //NS |
e.preventDefault(); |
e.stopPropagation(); |
} |
} |
catch (ex) { |
} |
} |
} |
</script> |
Regards,
Shinu.
0

Jignesh
Top achievements
Rank 1
answered on 19 May 2010, 06:38 PM
Hello Shinu
Thanks for quick reply.
your code is help ful but i need a validation and clear wrong value from the column.in your case suppose we copy and paste value in textbox than its not working.
i have some code its working fine for me. but i have one page in that i need to blank a column filtered value. other wise below code is working for display validation message.
Protected Sub test_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles test.ItemCommand
If e.CommandName = "Filter" Then
Dim filterPair As Pair = DirectCast(e.CommandArgument, Pair)
Dim filterOption As String = CType(e.CommandArgument, Pair).First
Dim filterPtrSaved As String = (DirectCast((TryCast(e.Item, GridFilteringItem))(filterPair.Second.ToString()).Controls(0), TextBox)).Text
Dim dcolumn As GridBoundColumn = Nothing
If e.CommandArgument.GetType.Name = "Pair" Then
dcolumn = CType(e.Item.OwnerTableView.GetColumnSafe(CType(e.CommandArgument, Pair).Second), GridBoundColumn)
End If
flgDispayError = True
If dcolumn.DataTypeName = "System.Decimal" Or dcolumn.DataTypeName = "System.Int32" Then
Dim num As Double
Dim isNumber As Boolean = Double.TryParse(filterPtrSaved, num)
If Not isNumber And filterOption <> "NoFilter" Then
RadAjaxManager1.ResponseScripts.Add("radalert('Please enter numeric data', 250, 125,'dotStaff');")
flgDispayError = False
End If
End If
If (Not filterOption = "IsNull" AndAlso Not filterOption = "NotIsNull" AndAlso Not filterOption = "NoFilter") AndAlso (dcolumn.DataTypeName = "System.DateTime") Then
Dim dFilterDate As DateTime
Dim dateStrings As String() = filterPtrSaved.Split(" ")
Dim isDate As Boolean = DateTime.TryParse(dateStrings(0), dFilterDate)
If Not isDate Then
RadAjaxManager1.ResponseScripts.Add("radalert('Please enter valid date.', 250, 125,'dotStaff');")
flgDispayError = False
End If
If flgDispayError AndAlso dateStrings.Length > 1 Then
isDate = DateTime.TryParse(dateStrings(1), dFilterDate)
If Not isDate Then
RadAjaxManager1.ResponseScripts.Add("radalert('Please enter valid date.', 250, 125,'dotStaff');")
flgDispayError = False
End If
End If
End If
End If
End Sub
please help me how i will do from the code behind?
Thanks
Jignesh Patel
Thanks for quick reply.
your code is help ful but i need a validation and clear wrong value from the column.in your case suppose we copy and paste value in textbox than its not working.
i have some code its working fine for me. but i have one page in that i need to blank a column filtered value. other wise below code is working for display validation message.
Protected Sub test_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles test.ItemCommand
If e.CommandName = "Filter" Then
Dim filterPair As Pair = DirectCast(e.CommandArgument, Pair)
Dim filterOption As String = CType(e.CommandArgument, Pair).First
Dim filterPtrSaved As String = (DirectCast((TryCast(e.Item, GridFilteringItem))(filterPair.Second.ToString()).Controls(0), TextBox)).Text
Dim dcolumn As GridBoundColumn = Nothing
If e.CommandArgument.GetType.Name = "Pair" Then
dcolumn = CType(e.Item.OwnerTableView.GetColumnSafe(CType(e.CommandArgument, Pair).Second), GridBoundColumn)
End If
flgDispayError = True
If dcolumn.DataTypeName = "System.Decimal" Or dcolumn.DataTypeName = "System.Int32" Then
Dim num As Double
Dim isNumber As Boolean = Double.TryParse(filterPtrSaved, num)
If Not isNumber And filterOption <> "NoFilter" Then
RadAjaxManager1.ResponseScripts.Add("radalert('Please enter numeric data', 250, 125,'dotStaff');")
flgDispayError = False
End If
End If
If (Not filterOption = "IsNull" AndAlso Not filterOption = "NotIsNull" AndAlso Not filterOption = "NoFilter") AndAlso (dcolumn.DataTypeName = "System.DateTime") Then
Dim dFilterDate As DateTime
Dim dateStrings As String() = filterPtrSaved.Split(" ")
Dim isDate As Boolean = DateTime.TryParse(dateStrings(0), dFilterDate)
If Not isDate Then
RadAjaxManager1.ResponseScripts.Add("radalert('Please enter valid date.', 250, 125,'dotStaff');")
flgDispayError = False
End If
If flgDispayError AndAlso dateStrings.Length > 1 Then
isDate = DateTime.TryParse(dateStrings(1), dFilterDate)
If Not isDate Then
RadAjaxManager1.ResponseScripts.Add("radalert('Please enter valid date.', 250, 125,'dotStaff');")
flgDispayError = False
End If
End If
End If
End If
End Sub
please help me how i will do from the code behind?
Thanks
Jignesh Patel