locked
how to pass data from controller so that we can add rows to jqgrid... RRS feed

  • Question

  • Controller

      public ActionResult GetAllDetail()
            {

            ViewBag.recipeDetails = recipeOperation.GetAllRecipes();
           
           return View(recipeOperation.GetAllRecipes());
            }

    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
        <script src="../../Scripts/jquery.jqGrid.js" type="text/javascript"></script>
        <script type="text/javascript">



            $("#recipetgridarray").jqGrid({
           
                datatype: "local",
                colNames: ["Recipe ID", "Recipe Name", "Price", "Description", "Mfg Date", "Expiry Date"],
                colModel: [
                    { name: "recipeId", index: "recipeId" },
                    { name: "recipeName", index: "recipeName" },
                    { name: "price", index: "price" },
                    { name: "description", index: "Description", sorttype: "int" },
                      { name: "mfgDate", index: "mfgDate" },
                      { name: "expiryDate", index: "expiryDate" },
                ],
                multiselect: true,
                shrinkToFit: false,
                caption: "Student List - Loading via Array"
            });

           
            var recipe = [
              { recipeId: "1", recipeName: "Pizza", price: 100, description: "Corn Pizza", mfgDate: " ", expiryDate: " " },
        
         
           ];
           
            for (var x = 0; x <= recipe.length; x++) {
              //  $("#recipegridarray").addRowData(x, recipe[x]);
               $("#recipegridarray").addRowData(x,'@(Model)');
            }
         
        

        </script>

    Monday, March 24, 2014 1:39 PM