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

How to send additional parameters on gird create method

7 Answers 889 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kalyani Mantripragada
Top achievements
Rank 1
Kalyani Mantripragada asked on 23 Sep 2013, 04:08 PM

Hi, I need to send in a bunch of form values to the create method (add new button) on the grid.
For edit, I used like this and it works fine.
grid call:
.Read(read => read.Action("Read_FinesByMLS", "FinesHistoryByMLS").Data("ParameterData"))

js function:
function ParameterData() {
         alert("para=" + $("#MLSNumber").val());
        return {
              MLSNumber: $("#MLSNumber").val()
        }
}

controller function:
public ActionResult Read_FinesByMLS([DataSourceRequest] DataSourceRequest request, string MLSNumber)
{
              using (var context = new MATRIXEntities_Connection ())
              {
                       IQueryable<FineHistory> finebymls = context.FineHistories;
                       if (MLSNumber != null)
                       {
                                  finebymls = finebymls.Where(f => f.MLSNumber == MLSNumber); }                       
                               DataSourceResult result = finebymls.ToDataSourceResult(request, f => new                    FineHistoryViewModel
                         {
                                   FineHistoryId = f.FineHistoryId ,
                                   FineCode = f.FineCode,
                             });
                            return Json(result);
                     }
}


When I tried to do same for create, I am not getting any value for the parameter in the controller function. MLSNumber param is coming null. Any help is appreciated. Thanks

here is my create action call.
.Create(create => create.Action("Create_FinesByMLS", "FinesHistoryByMLS").Data("ParameterData"))

Its the same function call as above for edit function.

Controller function.

public ActionResult Create_FinesByMLS([DataSourceRequest] DataSourceRequest request,  string MLSNumber)
      {
 
          using (var objFines_Context = new MATRIXEntities_Connection())
          {
 
              */
              //objFines_Context.usp_InsertFineHistory("211131297", "479", 4790, "713779DAF4844A", "239024", "281530", "kmantrip", "M");
              //objFines_Context.SaveChanges();
          }
          return View();
      }

the parameter is

7 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 25 Sep 2013, 09:58 AM
Hello Kalyani,


I was unable to reproduce the issue on my side. The syntax for sending the additional data to the create action is the same as the one to the read action. The Create action should accept an additional parameter with the newly created item (in InLine and PopUp edit mode), but that should not be the reason for the issue.

Could you please check the request headers in the Network tab of the developers console of your browser, to assure that the additional data is send correctly from the client side? If the issue is still persisting, please send me a sample project where it is reproducing, so I could inspect it locally and assist you further?

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Markus
Top achievements
Rank 1
answered on 30 Jan 2014, 04:41 PM
Hello,

when I want to pass a parameter to a controller action with the data-Methode, the parameter is null in my action.
I checked the request and the paramter is missing in the rawUrl and in the QueryString.
When I send the parameter direct in the read action (read.Action("Local_Data", "Home", new { name = "test"}) ) it works fine.
What could be the problem with the data-methode?

Here my Grid code:
@(Html.Kendo().Grid<KendoUIMvcApplication1.Models.ProductViewModel>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ProductName).Title("Product Name");
        columns.Bound(p => p.UnitPrice).Title("Unit Price").Width(130);
        columns.Bound(p => p.UnitsInStock).Title("Units In Stock").Width(130);
        columns.Bound(p => p.Discontinued).Width(130);
    })
    .AutoBind(false)
    .Pageable()
    .Sortable()
    .Scrollable(scr => scr.Height(430))
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        //.ServerOperation(false)
        .Read(read => read.Action("Local_Data", "Home").Data("Test"))
        //.Read(read => read.Action("Local_Data", "Home", new { name = "test"}))

     )


I tried to add a test project. But it was't successful. I try it later again.
0
Dimiter Madjarov
Telerik team
answered on 30 Jan 2014, 04:53 PM
Hi Markus,


Which Kendo UI version are you using? There is a known issue regarding the sending of additional data parameters in Q3 SP1 release i.e. version 2013.3.1316. If that is the currently used version, I would suggest you to upgrade it to Q3 SP2. If that is not the case, please send me a sample project, so I could inspect the issue locally and assist you further.

Have a great day!

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Markus
Top achievements
Rank 1
answered on 31 Jan 2014, 07:35 AM
Hi Dimiter,

yes I use the Version 2013.3.1316 SP1. I will try it with SP2.

Thank you very much.
0
Dimiter Madjarov
Telerik team
answered on 31 Jan 2014, 08:36 AM
Hello Markus,


Thanks for the update. Let me know if you experience further issues.


Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
tiffany
Top achievements
Rank 1
answered on 13 Feb 2014, 10:22 PM
Hello,

I had the same problem what Markus had. and i have already upgraded the version to q3 sp2 release 2013.3.1324. but the problem is still there, the parameter sent back to the controller is always null if it sent by the javascript funtion for the additional data. please help me to solve the problem, i already spent a lot of time on it.

Thanks a lot
tiffany
0
Dimiter Madjarov
Telerik team
answered on 14 Feb 2014, 08:21 AM
Hi Sai,


The issue is fixed in the Q3 SP2 release and I am unable to reproduce it on my side. Please make sure that all Kendo UI files are updated successfully. If the problem is still persisting, please send me an isolated example, where it is reproducing, so I could inspect it locally.

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Kalyani Mantripragada
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Markus
Top achievements
Rank 1
tiffany
Top achievements
Rank 1
Share this question
or