This is a migrated thread and some comments may be shown as answers.

EntityDataSource WhereParameters not working while AllowFilteringByColumn="true"

14 Answers 290 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dhamodharan
Top achievements
Rank 1
Dhamodharan asked on 23 May 2014, 12:58 PM
Hi All,

I am using EntityDataSource whereParameter working fine while AllowFilteringByColumn="false". but i want to set AllowFilteringByColumn="true" it returns error like "WhereParameters cannot be specified unless AutoGenerateWhere==true or Where is specified.". i set to AutoGenerateWhere==false in entitydatasource it returns error while filter like "AutoGenerateWhereClause cannot be true if Where is defined. ".

How do i solve this issue. Please let me know ASAP.

Thanks in advance,
Dhamodharan.S

14 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 28 May 2014, 10:51 AM
Hello,

I tried to replicate the problematic behavior by enabling the filtering in the online demo below but to no avail:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/manual-crud-operations/defaultcs.aspx

The mentioned example works properly on my side. Test it locally and verify what the difference in your case is.

Regards,
Maria Ilieva
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
Dhamodharan
Top achievements
Rank 1
answered on 22 Aug 2014, 08:12 AM
Hi,

I am using "EntitySetName" and "Include" in entitydatasource. without "Include" filtering working fine. while including another table we got this issue. Please let me know how we fix this issue
0
Dhamodharan
Top achievements
Rank 1
answered on 22 Aug 2014, 08:20 AM
sorry, this is not issue. while using AllowFilteringByColumn="True" i am not able to give Where="it.grp_ins_id=@grp_ins_id" in Entitydatasource. this is the problem. please let me know how to fix this issue
0
Jochen
Top achievements
Rank 2
answered on 09 Oct 2014, 10:41 AM
Same problem here. What I try to achieve is to combine the standard radgridview filter functionality with another filter, e. g. a Dropdown. How to do that with a entity data source?
0
Jochen
Top achievements
Rank 2
answered on 09 Oct 2014, 01:00 PM
Update: I found the MasterTableView Filterexpression property. I set that onInit in CodeBehind. Works fine in my case. But still interested in a solution with combined filters.
0
Dhamodharan
Top achievements
Rank 1
answered on 14 Oct 2014, 06:52 AM
Can you explain with sample code please?
0
Jochen
Top achievements
Rank 2
answered on 14 Oct 2014, 08:08 AM
Sure. This is what i figured out:

In codebehind you hook in OnInit (I guess OnLoad would be early enough too):

protected override void OnInit(EventArgs e)
{
// Registrieren der Events
c_Maingrid.ItemInserted += c_Maingrid_ItemInserted;

// Defaultfilter
c_Maingrid.MasterTableView.FilterExpression = "(it.[MANDNR] = " + Session["Mandant"] + ")";

// Basisklasse
base.OnInit(e);
}

The Radgrid (c_Maingrid) combines the MasterTableView.FilterExpression with the automatically generated filters in an "AND" manner. So you should achieve your goal.

You can hook in the EntityDataSource OnSelecting event to see how RadGrid is generating the filters.

Greets Jochen 

​
0
Dhamodharan
Top achievements
Rank 1
answered on 15 Oct 2014, 05:35 AM
when i added onlnit function
c_Maingrid.MasterTableView.FilterExpression = "(it.[MANDNR] = " + Session["Mandant"] + ")";

it is working fine. the grid populate without error message. but i want to filter by column. it is not working. can you please find that one.
0
Jochen
Top achievements
Rank 2
answered on 15 Oct 2014, 07:18 AM
Dhamodharan,

I do not really understand the question.

What I mean that you use the entity data source with default parameters like

<ef:EntityDataSource ID="c_DataSource" runat="server" ConnectionString="name=FELIXXEntities" DefaultContainerName="FELIXXEntities" EnableUpdate="true" EnableInsert="true" EnableDelete="true"
    EntitySetName="MANDANT">
</ef:EntityDataSource>

and you use the MasterTableView.FilterExpression INSTEAD of the EntityDataSource Where property to set a default filter. When yout enable the column filters of the RadGrid then the radgrid will handle the filtering by itself -> implicitly sets the EntityDataSource Where property and generates a combination of your default filter that you set in codebehind and the automatically generated column filter expressions. Unfortunately I can't attach the files here. 










0
Dhamodharan
Top achievements
Rank 1
answered on 15 Oct 2014, 07:52 AM
 Hi,

I used Entitydatasource selecting event for where condtion. so first time that grid retrive record correcty based on where condition. but going to filter condtion based column "StartsWith". that time i have following error message
"Sys.WebForms.PageRequestManagerServerErrorException: The query syntax is not valid. Near keyword 'LIKE', line 6, column 6. "

Please check my code
<asp:EntityDataSource ID="EDSPlans" runat="server" ConnectionString="name=GrpEntities"
DefaultContainerName="GrpEntities" EnableDelete="True" EnableFlattening="False"
EnableInsert="True" EnableUpdate="True" EntitySetName="PLANS" Include="plan_types, plan_funding_types"
OrderBy="it.EFFECTIVE_DATE DESC" EntityTypeFilter=""
Select="">
</asp:EntityDataSource>


Protected Sub EDSPlans_Selecting(sender As Object, e As System.Web.UI.WebControls.EntityDataSourceSelectingEventArgs) Handles EDSPlans.Selecting

If e.DataSource.Where <> String.Empty Then
e.DataSource.Where += " AND "
End If
e.DataSource.Where += "it.grp_id=1"
        
End Sub
0
Jochen
Top achievements
Rank 2
answered on 15 Oct 2014, 07:58 AM
Thats a lot more information than you initial question :)

Could you debug and post the Where condition itself? Maybe there's a bug generating the where statement?

Maybe you'll have to correct the Where condition manually within the event.

From now on I think I cannot deliver any valuable information...
0
Dhamodharan
Top achievements
Rank 1
answered on 15 Oct 2014, 09:23 AM
Hi,

I have another Question. Can we insert data into 2 tables?. i am using EntityDataSource with
"Inclue" option. so i can display 2 tables data. but how we can insert
and update 2 tables?
0
Jochen
Top achievements
Rank 2
answered on 15 Oct 2014, 09:34 AM
Good explanation for asp DataGrid here:

http://stackoverflow.com/questions/2284374/columns-of-two-related-database-tables-in-one-asp-net-gridview-with-entitydataso

Quite sure this is the same for RadGrid.

I think you have to solve that on entity level using foreign keys afaik - we are also researching this right at the moment. But post your solution when you have it... I'm interested :)

0
Dhamodharan
Top achievements
Rank 1
answered on 20 Oct 2014, 05:36 AM
Thanks for your help. i need another help. i need case inSensitive while filtering. but now it is filtering like caseSensitive. i set the property like  "<GroupingSettings CaseSensitive="False" />". but not working. i am using Oracle database. can we set any additional property please let me know ASAP.
Tags
Grid
Asked by
Dhamodharan
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Dhamodharan
Top achievements
Rank 1
Jochen
Top achievements
Rank 2
Share this question
or