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

Problem in Filter data

5 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mina
Top achievements
Rank 1
mina asked on 31 May 2012, 01:59 PM

I use AJAX-enable WCF service  and kendo ui grid

I want filter data but my code not work .

Plz help me to find  problem

thanks

Wcf service method:

 

 

[OperationContract]
        public IEnumerable<PrpductGroup2> ReadGroupProduct()//int id
        {
            Manager.PrpductGroupManager pGroupManage = new Manager.PrpductGroupManager();
            List<Common.PrpductGroup> pGroupMain = new List<Common.PrpductGroup>();
 
            pGroupMain = pGroupManage.Where(g => g.Type != null).ToList();
 
            List<PrpductGroup2> MG = new List<PrpductGroup2>();
            foreach (var item in pGroupMain)
            {
                var mg1 = new PrpductGroup2();
                mg1.PrpductGroup = item.PrpductGroup1;
                mg1.PrpductGroupID = item.PrpductGroupID;
                mg1.Type = item.Type;
 
                MG.Add(mg1);
            }
 
            return MG;
        }


And my script for grid:

$("#GridPrpductGroup").kendoGrid({
            height: 300,
            autoSync: true,
            navigatable: true,
            columns: [
        { command: ["edit", "destroy"], title: " ", width: "210px" },
              { field: "Type", title: "گروه اصلی کالا" },
              { field: "PrpductGroup", title: "گروه کالا" },
              { field: "PrpductGroupID", title: "ردیف" }
 
            ],
 
            dataSource: {
                schema: {
                    data: "d",
                    total: "d.length",
                    serverPaging: true,
                    serverSorting: true,
                    serverFiltering: true,
                    filter: { field: "Type", operator: "eq", value: idForFilter },
                    model: {
                        id: "PrpductGroupID",
                        fields: {
                            PrpductGroup: "PrpductGroup",
                            PrpductGroupID: { editable: false, nullable: true },
                            Type: "Type"
                        }
                    }
                },
                batch: true,
                 
                pageSize: 6,
                transport: {
                    read: {
           contentType:"application/json; charset=utf-8",                       type: "POST"
                    },
                    update:
                       {
         url:"/EveryOne/ForgotService.svc/UpdateGroupProduct",            contentType:"application/json; charset=utf-8",
           type: "POST"
                             },
                    parameterMap: function (data, operation) {
                     if (operation !== "read") {
                          return JSON.stringify({ properties:data.models })
                        }
                    }
                }
            },
            pageSize: 6,
            scrollable: true,
            sortable: true,
            pageable: true,
            editable: "inline"
 
        });

 

 

 

5 Answers, 1 is accepted

Sort by
0
mina
Top achievements
Rank 1
answered on 01 Jun 2012, 03:41 AM
please help me
0
Mentor Graphics
Top achievements
Rank 1
answered on 01 Jun 2012, 09:23 AM
Hi Mina,
I have similar issue - in my case (code looks pretty much as your code) - in my case, empty request is being passed to the server
for the update,create and delete events.
0
mina
Top achievements
Rank 1
answered on 01 Jun 2012, 11:06 AM

Hi Yaniv

Thanks for reply. With your request , I realized where is the problem. I didn’t try update ,.. because I wrote similar code before, then I copy that code in new page.

But I forgot to change a part of code .

The update method in server has an argument that name is (“mainGroup”) (in my code)

In script for kendo grid , in this part of code should write argument name

parameterMap: function (data, operation) {

                        if (operation !== "read") {

                            return JSON.stringify({ mainGroup: data.models })

                        }

                    }

When I copy code I forgot change method name and my code didn’t work

I hope you can use this code.
My english is very bad . I  hope you undrestand my writting
Again thanks for reply dear Yaniv

0
Mentor Graphics
Top achievements
Rank 1
answered on 01 Jun 2012, 11:48 AM
Hi Mina,
can you please provie the server update method ?
Tnx
0
mina
Top achievements
Rank 1
answered on 01 Jun 2012, 12:05 PM
yes of course
I thougth put update method here

it's my  update method
get an argument "mainGroup"
In create you should notice that input argument name in update or create method  equal to a part of code that I said before
and all of kendo grid's code is in my first post

[OperationContract]
  public void UpdateMainGroupProduct(IEnumerable<MainGroupProduct2> mainGroup)
  {
      foreach (var pGroup in mainGroup.ToList())
      {
          Common.PrpductGroup propGroupObj = new Common.PrpductGroup();
 
          Manager.PrpductGroupManager pMainGroupmanage = new Manager.PrpductGroupManager();
          propGroupObj = pMainGroupmanage.Single(p => p.PrpductGroupID == pGroup.PrpductGroupID);
          propGroupObj.PrpductGroup1 = pGroup.PrpductGroup;
 
          pMainGroupmanage.Change(propGroupObj);
      }
  }

Tags
Grid
Asked by
mina
Top achievements
Rank 1
Answers by
mina
Top achievements
Rank 1
Mentor Graphics
Top achievements
Rank 1
Share this question
or