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
Bug in cmTemplate (new Feature)
18/03/2011
20:11
Avatar
Crazy108
Ukraine
Member
Members
Forum Posts: 5
Member Since:
18/03/2011
sp_UserOfflineSmall Offline

I use next code:

<script src="/templates/default/js/jqgrid/js/i18n/grid.locale-ru.js"></script>

<script type="text/javascript">
    $.jgrid.no_legacy_api = true;
    $.jgrid.useJSON = true;
</script>

<script src="/templates/default/js/jqgrid/jquery.jqGrid.js"></script>

<script type="text/javascript">
    $.extend($.jgrid.defaults, { cmTemplate:{ formoptions:{ elmprefix:'&nbsp;&nbsp;&nbsp;&nbsp;' } } );
</script>

In colModel 2 from 10 rows have elmprefix

    colModel: [
        {name: "id_traders", width:1, hidden:true, hidedlg:true, key:true, search:false},
        {name: "title", index:"title",
            sortable:true, sorttype:"text", firstsortorder:"asc",
            editable:true, editrules:{required:true},
        },
        {name: "name", index:"name", hidden:true, hidedlg:true, search:false,
            sortable:true, sorttype:"text", firstsortorder:"asc",
            editable:true, editrules:{edithidden:true,required:true}, formoptions:{elmprefix:'<font color="red">(*)</font>', elmsuffix:'<br />&nbsp;&nbsp;&nbsp;&nbsp;Уникальный идентификатор биржи. Большими буквами.'}
        },

        {name: "api", index:"api", search:false, hidden:true,
            sortable:true, sorttype:"text", firstsortorder:"asc",
            editable:true, editrules:{edithidden:true}, formoptions:{label:"Активен"}
        },

....... more......

If in colModel presend "formoptions:{label:"Активен"}" OR more attributes - default settings cmTemplate:{ formoptions:{ elmprefix:'&nbsp;&nbsp;&nbsp;&nbsp;' } }" do not work!

Why?

sorry my bad english

18/03/2011
21:16
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello!

It is not a bug. The problem is that you try to use correspond to my original sugestion and not correspond to its implementation in jqGrid. You should define cmTemplate as the jqGrid parameter and not as the default setting $.jgrid.defaults.cmTemplate. Moreover you want use the setting not for all columns you can use template property of colModel instead.

For example you define

var myGeneralFormOption={ formoptions:{ elmprefix:'&nbsp;&nbsp;&nbsp;&nbsp;' } }

and then use it in the column where you need it:

{name: "api", index:"api", search:false, hidden:true, template:myGeneralFormOption,
  sortable:true, sorttype:"text", firstsortorder:"asc",
  editable:true, editrules:{edithidden:true}, formoptions:{label:"Активен"}
}

You can look at the demo from my another sugestion.

Best regards
Oleg 

21/03/2011
12:26
Avatar
Crazy108
Ukraine
Member
Members
Forum Posts: 5
Member Since:
18/03/2011
sp_UserOfflineSmall Offline

Thanks for support
Option with $. jgrid.defaults.cmTemplate as global settings, would be much more convenient to use

Additional info:

update script -

var myOption={ formoptions:{ elmprefix:'&nbsp;&nbsp;&nbsp;&nbsp;' } }

and in colModel

        {name: "api", index:"api", search:false, hidden:true, template:myOption,
            sortable:true, sorttype:"text", firstsortorder:"asc",
            editable:true, editrules:{edithidden:true}, formoptions:{label:"Активен", colpos:1}
        },

No effects. Field api not have default options

If colModel change on :

        {name: "api", index:"api", search:false, hidden:true, template:myOption,
            sortable:true, sorttype:"text", firstsortorder:"asc",
            editable:true, editrules:{edithidden:true},/* formoptions:{label:"Активен", colpos:1}*/
        },

All OK. &nbsp;...... inserts in field row

In grid.base.js code is used

        for (i=0; i<ts.p.colModel.length;i++) {
            ts.p.colModel[i] = $.extend({}, ts.p.cmTemplate, ts.p.colModel[i].template || {}, ts.p.colModel[i]);

            if (ts.p.keyIndex === false && ts.p.colModel[i].key===true) {
                ts.p.keyIndex = i;
            }
        }

 and no difference where to insert this template …

var myOption={ formoptions:{ elmprefix:'&nbsp;&nbsp;&nbsp;&nbsp;' } }

OR

    $.jgrid.defaults.cmTemplate = {};
    $.jgrid.defaults.cmTemplate.formoptions = { elmprefix:'&nbsp;&nbsp;&nbsp;&nbsp;' };

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
28 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