1. #1
    Ext User
    Join Date
    May 2009
    Posts
    2
    Vote Rating
    0
    zeeshanhanif is on a distinguished road

      0  

    Default Problem in Applying Grid-Filter

    Problem in Applying Grid-Filter


    I m facing the problem in applying grid-filters.when i run the application i got the error in firebug

    Ext.grid.GridFilters is not a constructor

    i cant understand what the issue is that.is there something wrong with GridFilters.js or with my code.

    my js file code to render the grid:

    // Start grid-render.js ------------

    Ext.onReady(function() {

    var store = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy(
    new Ext.data.Connection({
    url:'sendTwoPaging2.jsp'
    })
    ),
    reader:new Ext.data.JsonReader({
    totalProperty:'total',
    root:'rows',
    id:'id',
    fields:['id', 'systemName' , 'interfaceName' , 'timeIn' , 'status' , 'timeOut']
    }),
    remoteSort:true
    });

    // Define the filters for the fields:
    // code, applicationname, useremail, action, message, messagetime
    var filters = new Ext.grid.GridFilters({
    filters:[
    {type: 'string', dataIndex: 'id'},
    {type: 'string', dataIndex: 'systemName'},
    {type: 'string', dataIndex: 'interfaceName'},
    {type: 'string', dataIndex: 'timeIn'},
    {type: 'string', dataIndex: 'status'},
    {type: 'string', dataIndex: 'timeOut'}
    ]});


    var cm = new Ext.grid.ColumnModel([
    {header:'ID', width:120, sortable:true, dataIndex:'id'},
    {header:'System Name', width:120, sortable:true, dataIndex:'systemName'},
    {header:'Interface Name', width:120, sortable:true, dataIndex:'interfaceName'},
    {header:'Time In', width:120, sortable:true, dataIndex:'timeIn'},
    {header:'Status', width:120, sortable:true, dataIndex:'status'},
    {header:'Time Out', width:120, sortable:true, dataIndex:'timeOut'}

    ]);
    cm.defaultSortable = true;

    var grid = new Ext.grid.GridPanel({
    el:'pagingJson-grid',
    storetore,
    cm:cm,
    //sm: new Ext.grid.RowSelectionModel({selectRow:Ext.emptyFn}),
    viewConfig:{
    forceFit:true
    },
    title:' grid title',
    width:500,
    height:500,
    loadMask:true,
    frame:false,
    plugins: filters,
    bbar:new Ext.PagingToolbar({
    pageSize:10,
    storetore,
    displayInfo:true,
    displayMsg: '{0} - {1}',
    plugins: filters,
    emptyMsg:'No data'
    })
    });

    grid.render();
    store.load({params:{start:0, limit:10}});
    //store.load();

    });

    // End grid-render.js ---------

    and my JSP file code where i m applying the queries

    // Start dataHandler.jsp ----


    <%@page import="com.logging.CreateJson"%>
    <%
    CreateJson json=new CreateJson();

    String start = (request.getParameter("start") == null) ? "0" : request.getParameter("start");
    String limit = (request.getParameter("limit") == null) ? "10" : request.getParameter("limit");
    String sort = (request.getParameter("sort") == null) ? "" : request.getParameter("sort");
    String dir = (request.getParameter("dir") != null && request.getParameter("dir").equalsIgnoreCase("desc")) ? "DESC" : "";

    int st=Integer.parseInt(start);
    int lmt=Integer.parseInt(limit);
    StringBuilder whereClause = new StringBuilder();

    // whereClause.append(" 1 = 1 ");
    int wlen = whereClause.length();
    for (int i = 0; request.getParameter("filter[" + i + "][field]") != null; i++)
    {
    String prefix = "filter[" + i + "]";
    String field = request.getParameter(prefix + "[field]");
    String type = request.getParameter(prefix + "[data][type]");
    String value = request.getParameter(prefix + "[data][value]");

    if (type.equalsIgnoreCase("string"))
    {
    // Allow the user to define there own wildcards
    if (value.indexOf('*') >= 0)
    {
    value = value.replace('*', '%');
    whereClause.append(" AND " + field + " LIKE '" + value + "' ");
    }
    else
    {
    whereClause.append(" AND " + field + " LIKE '%" + value + "%' ");
    }
    }
    else if (type.equalsIgnoreCase("date"))
    {
    String dateval = value.substring(6) + "-" + value.substring(0, 2) + "-" + value.substring(3, 5);
    String operand = request.getParameter(prefix + "[data][comparison]");
    if (operand.equals("lt"))
    {
    whereClause.append(" AND m.date <= '" + dateval + " 23:59:59'");
    }
    else if (operand.equals("gt"))
    {
    whereClause.append(" AND m.date >= '" + dateval + "'");
    }
    else if (operand.equals("eq"))
    {
    whereClause.append(" AND m.date >= '" + dateval + "'");
    whereClause.append(" AND m.date <= '" + dateval + " 23:59:59'");
    }
    }
    else if (type.equalsIgnoreCase("list"))
    {
    if (value.indexOf(',') != -1)
    {
    String values[] = value.split(",");

    StringBuilder inValue = new StringBuilder();
    boolean first = true;
    for (String val : values)
    {
    if (first)
    {
    inValue.append("'").append(val).append("'");
    first = false;
    }
    else
    {
    inValue.append(", '").append(val).append("'");
    }
    }

    whereClause.append(" AND ").append(field).append(" IN (").append(inValue.toString()).append(") ");
    }
    else
    {
    whereClause.append(" AND ").append(field).append(" = '").append(value).append("' ");
    }
    }
    }

    // Build the sql query
    //String query="select * from ( select a.* , ROWNUM rnum from LOG_REQUEST_REPLY1 a where ROWNUM<="+ limit+
    //")where rnum > " + start + "";

    StringBuilder query = new StringBuilder();
    StringBuilder queryCount = new StringBuilder();
    query.append("SELECT * from ( SELECt a.* , ROWNUM rnum from LOG_REQUEST_REPLY1 a ");
    //queryCount.append("SELECT COUNT(text) from ((`message` `m` join `application` `a`) join `user` `u`) where ((`m`.`applicationid` = `a`.`id`) and (`m`.`userid` = `u`.`id`))");
    if (whereClause.length() > wlen) {
    // we have to insert the where part...
    query.insert((query.length() - 1), whereClause);
    queryCount.insert((queryCount.length() - 1), whereClause);
    // query.append(" WHERE " + whereClause.toString());
    }
    if (sort != null && !sort.equals("")) {
    query.append(" ORDER BY ").append(sort).append(" ").append(dir);
    }

    query.append("WHERE ROWNUM<= ").append(lmt).append(") WHERE rnum>").append(st);

    //System.out.println("query: " + query.toString());
    //System.out.println("queryCount: " + queryCount.toString());

    String a=json.getJson(query.toString());

    out.println(a);
    %>



    // End dataHandler.jsp ----

    can anybody help me.thanks in advance;

  2. #2
    Ext User 666ragez666's Avatar
    Join Date
    Jan 2009
    Posts
    110
    Vote Rating
    0
    666ragez666 is on a distinguished road

      0  

    Default


    please make sure you are including the grid filter declaration before using it.

  3. #3
    Ext User
    Join Date
    May 2009
    Posts
    2
    Vote Rating
    0
    zeeshanhanif is on a distinguished road

      0  

    Default


    I have included the javascript in my html code.where i have to declare the grid-filter.

    here below is the html code

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>Paging Grid Example</title>

    <link rel="stylesheet" type="text/css" href="ext-all.css"/>
    <link rel="stylesheet" type="text/css" href="examples.css"/>
    <link rel="stylesheet" type="text/css" href="xtheme-aero.css"/>
    <link rel="stylesheet" type="text/css" href="grid-examples.css"/>

    <script type="text/javascript" src="/grid-filters/EditableItem.js"></script>
    <script type="text/javascript" src="/grid-filters/RangeMenu.js"></script>


    <!-- Grid Filters Java Script Files -->
    <script type="text/javascript" src="/grid-filters/GridFilters.js"></script>
    <script type="text/javascript" src="/grid-filters/filter/BooleanFilter.js"></script>
    <script type="text/javascript" src="/grid-filters/filter/DataFilter.js"></script>
    <script type="text/javascript" src="/grid-filters/filter/Filter.js"></script>
    <script type="text/javascript" src="/grid-filters/filter/ListFilter.js"></script>
    <script type="text/javascript" src="/grid-filters/filter/NumericFilter.js"></script>
    <script type="text/javascript" src="/grid-filters/filter/StringFilter.js"></script>
    <!-- END Grid Filters Examples -->

    <script type="text/javascript" src="ext-base.js"></script>
    <script type="text/javascript" src="ext-all.js"></script>
    <script type="text/javascript" src="twopaging.js"></script>


    </head>
    <body>
    <br/>
    <br/>
    <div id="pagingJson-grid"></div>
    </body>
    </html>

Thread Participants: 1