Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Updated jqGrid to include a message box in Search box for server messages
17/09/2008
16:56
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

I have an issue with errors on the server, like for example when the user selects to search by ID, the "contains" option is not really applicable as I use NHibernate Criterias which do not allow this kind of criteria for reasons I don't want to clutter this discussion with. So I also did not want an alert after LoadError, especially since I "tune" my search to return the previous result set if the search is "invalid" on my server so no LoadError happens. Below is the code updates I made to jqGrid to display a message box below the search line that is popolated from the server in a "Message" property that I added to the Jsonreader. It works great, feel free to add it to the next release it sure helped me.

  • myjQuery.js file:

            jsonReader:{
              root: "Addresses",
              page: "CurrentPage",
              total: "TotalPages",
              records: "TotalRecords",
              message: "Message",
              repeatitems: false,
              id: "0"
            },

  • grid.css

/*    Added by Renso to support messages from the server concerning the search results*/
div.modalwin.jqmWindow.jqmID1 div.modalcontent table tr#msgrow td input#rsltmsg    {
    margin: 2px;
    width: 98%;
    font-size: 10px;
    color: #15428B;   
}

  • grid.formedit.js

$.fn.extend({
    searchGrid : function ( p ) {
        p = $.extend({
            top : 0,
            left: 0,
            width: 380, //Renso: changed from 360
            height: 90, //Renso: changed from 70

            modal: false,

                // field and buttons
                var sField  = "<input id='sval' class='search' type='text' size='20' maxlength='100'/>";
                var bSearch = "<input id='sbut' class='buttonsearch' type='button' value='"+p.Find+"'/>";
                var bReset  = "<input id='sreset' class='buttonsearch' type='button' value='"+p.Reset+"'/>";
                var tmsg  = "<input id='rsltmsg' class='message' type='text' value='' readOnly=true'/>";
                //Renso: var cnt = $("<table width='100%'><tbody><tr><td>"+cNames+"</td><td>"+sOpt+"</td><td>"+sField+"</td><td>"+bSearch+"</td><td>"+bReset+"</td></tr></tbody></table>");
                //Renso: updated by adding row for comment
                var cnt = $("<table width='100%'><tbody><tr><td>"+cNames+"</td><td>"+sOpt+"</td><td>"+sField+"</td><td>"+bSearch+"</td><td>"+bReset+"</td></tr><tr id='msgrow'><td colspan=5>"+tmsg+"</input></td></tr></tbody></table>");

grid.base.js

            endReq();
            updateMessage();    //Renso: added to update the message for errors in searching
            updatepager();
        };
        var updateMessage = function() {
            if(ts.p.message) {
                $('div.modalwin.jqmWindow.jqmID1 div.modalcontent table tr#msgrow td input#rsltmsg').val(ts.p.message );
            }
        };

        var updatepager = function() {

That's it. Cool

17/09/2008
17:00
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Left out an important piece in grid.base:

        var addJSONData = function(data,t) {
            if(data) { $("tbody tr:gt(0)", t).remove(); } else { return; }
            var row,f=[],cur,gi=0,si=0,drows,idn,rd=[],cn=(ts.p.altRows===true) ? 'alt':'';
            ts.p.page = data[ts.p.jsonReader.page];
            ts.p.lastpage= data[ts.p.jsonReader.total];
            ts.p.records= data[ts.p.jsonReader.records];
            //Renso: added message property for handling server side message during searches
            ts.p.message= data[ts.p.jsonReader.message];

17/09/2008
17:16
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

If you want to add hiding and displaying of the message based on content you can also do in grid.base.js:

        var updateMessage = function() {
            if(ts.p.message) {
                if(ts.p.message.length > 0)    {
                    $('div.modalwin.jqmWindow.jqmID1 div.modalcontent table tr#msgrow td input#rsltmsg').val(ts.p.message).show();
                    return;
                }
            }
            $('div.modalwin.jqmWindow.jqmID1 div.modalcontent table tr#msgrow td input#rsltmsg').val("").hide();
        };

22/09/2008
08:45
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I do not answerd of this since I think you will find a more easy solution.

I do not known which version do you use but lets look at jsonReader

and xmlReader.

        var jReader = {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: true,
            cell: "cell",
            id: "id",
            userdata: "userdata",
            subgrid: {root:"rows", repeatitems: true, cell:"cell"}

The same can be achieved without touch the code using the userdata

The problem was that in the search dialog there was no place for

the errors. In the upcomming release I have added this and so you can

easy add the custom message here.

Also I have added a special message function for this purpose.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

22/09/2008
13:27
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Tony, I am in the middel of my project and just need a basic idea of when you think the new release with the custom message for search (and edit/add modal dialog) will be done so I will know if it is going to come in time?

22/09/2008
14:05
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Tony by the way, you are right (as always) the userdata is so much easier to set up and get via getUserData(), thanks for the help.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
40 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information