This project is read-only.
This is an example webmethod that jqGrid could post to and would receive an XML response that would work with jqGrid without additional configuration.
[WebMethod(EnableSession = true)]
        public JqGrid.XML.JQGrid GetTraderMarkedCurves(string _search, string page, string rows, string sidx, string sord, string filters)
            DataTable dt;
            GridSettings gs = new GridSettings(_search, page, rows, sidx, sord, filters);
               dt  = DataAccess.GetData(gs, Session);
                // do something here maybe throw an error that your ajax request can pick up on and handle
            JqGrid.XML.JQGrid jqgrid = JqGrid.XML.JqgridHelper.GetJQGrid(dt, gs);
            return jqgrid;

This is how you would use the grid settings and filter expression method to to alter your query string to return the desired results. The filter expression method properly handles all sorts of different data types. see code for reference.

 public static DataTable GetData(GridSettings gs, HttpSessionState session )

            //calpinequerybuilder is an in house library for executing queries but you get the idea
            CalpineQueryBuilder myDB = (CalpineQueryBuilder)session["MyDB"];

            string sql = "select * from some_table"

//the GetFilterExpression method given a type of data object you want to query will build a filter 
//expression specific to that type
            string filterExpression = gs.GetFilterExpression(ExpressionParserFactory.ExpressionParserType.Oracle);
            string orderByExpression = gs.GetOrderByExpression();
            if (filterExpression != "")
                sql += " where" + filterExpression;
            if (orderByExpression != "")
                sql += " order by " + orderByExpression;

            SQL_Statement sqlStatement = new SQL_Statement();
            DataSet ds = new DataSet();

            sqlStatement.SQL_Name = "Get Trader Marked Curves";
            sqlStatement.SQL_String = sql;
            myDB.Exec_SQL_Statement_To_DataSet(out ds, ref sqlStatement);

            return ds.Tables[0];

Last edited Mar 13, 2012 at 8:41 PM by jmsunseri, version 4


No comments yet.