Serverside with Asp.net MVC

Serverside with Asp.net MVC

BerryBerry Posts: 3Questions: 0Answers: 0
edited December 2010 in Plug-ins
I'am really a fan of this and i'am using it for some time now. The problem is that i used it for small table and now i'am doing a project where the supplier is a big, big database. People run queries against the database, so columns and number of rows can not be fixed.
I'am trying now for several days to get anything working with server-side in asp.net MVC. No gain what so ever.

Maybe I'am thing to deep, maybe I know less than I thought :).

This is my controller who will fetch the data for me:

public ActionResult Index()
{
DataTable dt = new DataTable();

if (Mycon.ActivateConnection())
{
myDQL.Error += new DCTMLIB.XDQLEventHandler(DQLFout);

dt = myDQL.ExecuteDQLSelect_byCollections("Select * from sl", Mycon.con);
myDQL.Error -= new DCTMLIB.XDQLEventHandler(DQLFout);
}

DQLModel m = new DQLModel { DQLData = dt };
return View(m);
}

This datatable must be passed to the DataTable. I wrote in my index.aspx page:






Workflow reporting

$(function () {
$('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": false
<?????? Does anything have to come here ?????>
});
});




Please help. If possible with code!

Replies

  • LionHeartLionHeart Posts: 8Questions: 0Answers: 0
    edited December 2010
    Salut,
    Je pense qu'il te manque effectivement, si tu es en server-side processing, une r
  • BerryBerry Posts: 3Questions: 0Answers: 0
    Thanks Lionheart,

    The problem -besides not knowing how to do this- is that users type there sql, so i do not know what columns to use. I've tried to inject the table with the columns and data in the header and the body. This works fine but slow. The advantace is that i do not need to botter for sorting or other things because I can you standard functionality.

    I looked at your example and i will give it a try. If it works I try to make a standaard class of it so i can re-use it over and over again.
  • BerryBerry Posts: 3Questions: 0Answers: 0
    Guys, this is giving me a headache.

    I've looked at the several scripts and tried to make something out of it. I just do not know why this is so hard. Must be my problem I think:)

    I'll give it a try to explain again.

    The code below is a part of my index.aspx in a MVC asp.net project.




    $(document).ready(function () {
    $('#example').dataTable({
    "sPaginationType": "full_numbers",
    "bStateSave": true,
    "bJQueryUI": true,
    "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
    "iDisplayLength": 25,
    "bProcessing": true,
    "bServerSide": true,
    "bAutoWidth": false,
    "url": '/Home/GridData/'
    });
    });



    The code below is the full homecontroller class.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using DKC_Web.Models;
    using DKC_Web.Library;
    using System.Data;

    namespace DKC_Web.Controllers
    {
    [HandleError]
    public class HomeController : Controller
    {
    Connectclass Mycon = new Connectclass();
    DCTMLIB.PDQL myPQL = new DCTMLIB.PDQL();

    public ActionResult Index()
    {
    ViewData["Message"] = "Welcome to ASP.NET MVC!";

    return View();
    }


    [HttpPost]
    public ActionResult GridData(FormCollection form)
    {
    jsonDataTable.DataTablesResponse _response = new jsonDataTable.DataTablesResponse();
    if (Mycon.ActivateConnection())
    {

    DataTable dt = new DataTable();
    dt = myPQL.ExecuteDQLSelect_byCollections("Select * from sl", Mycon.con);
    PQLModel m = new PQLModel { PQLData = dt };

    _response.iTotalDisplayRecords = dt.Rows.Count;
    _response.iTotalRecords = dt.Rows.Count;
    _response.sEcho = Request["sEcho"];
    _response.aaData = m.CreateJson();
    }
    return Json(_response);

    }

    public ActionResult GridData_org(string sidx, string sord, int page, int rows)
    {
    int totalPages = 1; // we'll implement later
    int pageSize = rows;
    int totalRecords = 3; // implement later

    var jsonData = new
    {
    total = totalPages,
    page = page,
    records = totalRecords,
    rows = new[]{
    new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
    new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
    new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
    }
    };
    return Json(jsonData);
    }

    public ActionResult About()
    {
    return View();
    }
    }
    }

    It just does work and it does not matter if I use the Griddata or GridData_org. In both cases I receive the error:
    Microsoft JScript runtime error: Object expected

    Please help, advise, solve......
  • LionHeartLionHeart Posts: 8Questions: 0Answers: 0
    edited December 2010
    Yop,
    As tu vraiment besoin de combiner le server-side processing ET le fait que les utilisateurs tapent eux m
This discussion has been closed.