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
How to insert jqgrid in the edit form of another jqgrid?
27/02/2011
14:40
Avatar
Wafaas
Member
Members
Forum Posts: 7
Member Since:
04/11/2010
sp_UserOfflineSmall Offline

Hi,

I really appreciate help, and below is the scenario.

I have jqgrid with certain customization to show and hide columns in the edit form, and i want to customize the edit form to include another simple jqgrid which contains 2 columns only id and name in order to add or edit it instantly inside the form.

Thanks,

27/02/2011
15:20
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello,

Your scenario seems me too complex, but if you really need to add any additional HTML element in the edit form you can do this inside of beforeShowForm event handler. You can for example use jQuery.insertAfter or close jQuery functions to insert any HTML fragment in the form. See for example Add dialog of this example.

Best regards
Oleg 

27/02/2011
19:00
Avatar
Wafaas
Member
Members
Forum Posts: 7
Member Since:
04/11/2010
sp_UserOfflineSmall Offline

Yes, i already used insertAfter and insertBefore to move some HTML elements.

Would you look at this code, i successfully inserted autocomplete plugin into the edit form but i failed to do the same for a simple jqgrid, please tell me if it is possible to modify and make it work or i should look for another solution.

    jQuery(document).ready(function(){

      var url ="<%= request.getContextPath() %>/GetHotDocs?detailsType=HotDoc";
      var editurl ="<%= request.getContextPath() %>/UpdateHotDocs?detailsType=HotDoc";
        var autocompleteurl ="<%= request.getContextPath() %>/GetAutoCompleteData";
        var mydata = [{id:"1",name:"install"}, {id:"2",name:"monitor"}, {id:"3",name:"backup"}];
        /*for(var i=0;i<=mydata.length;i++) {
            jQuery("#associatedlist").jqGrid('addRowData',i+1,mydata[i]);
        }*/
            
      jQuery("#hotdocgrid").jqGrid({
        url: url+"&item="+ $('#concept_name').text()+ "&catg="+$('#concept_category').text().trim(),
        datatype: "json",  
        colNames:['id','LinkTitle','Title', 'URL', 'Concept','ConceptX','ConceptY','Category', 'Concept2', 'Concept3', 'Concept4', 'Concept5'],
        colModel:[      
                      {name:'id',index:'id', hidden:true},
                    {name:'LinkTitle',index:'LinkTitle', width:40, sortable:false},
                    {name:'Title',index:'Title', width:40, hidden:true, sortable:false,editable:true, editrules:{required:true, edithidden:true},
                     editoptions:{size:50}
                    },                           
                    {name:'url',index:'url',width:40,hidden:true, sortable:false, editable:true, editrules:{required:true,edithidden:true},
                    //{name:'url',index:'url',width:40,sortable:false, editable:true, editrules:{required:true},
                      editoptions:{size:50},formoptions:{elmprefix:'<div id="form_concept_head"><b>Concepts:</b></div>'}    
                    },                         
                    {name:'Product1',index:'Product1', width:40, sortable:false, editable:true, editrules:{required:true},
                      editoptions:{
                        size:50,                             
                         dataInit: function(elem) {
                            $(elem).autocomplete(autocompleteurl, {
                                  minChars:3,
                                scroll: true,
                                scrollHeight: 200,
                                limit:200,
                                extraParams:{catg:'Product'},
                                autoFill: false,
                                noCache:true
                               });
                           $(elem).result(function(event, data, formatted) {
                           if (data)
                               $("#Product1").val(data[1]);
                           });
                           
                           $(elem).autocomplete(autocompleteurl, {
                                  minChars:3,
                                scroll: true,
                                scrollHeight: 200,
                                limit:200,
                                extraParams:{catg:'Activity'},
                                autoFill: false,
                                noCache:true
                               });}},                        
                        formoptions:{label: '*Product', elmsuffix:'<div id="prod_addrow"><input id="addprodRow" '+
                              'colspan="2" type="button" class="addRow" value="Add" /></div>'}
                    },
                    {name:'Category',index:'Category', width:40, sortable:false},                         
                    {name:'Activity1',index:'Activity1',width:40,hidden:true, sortable:false, editable:true, editrules:{required:false,edithidden:true},
                      editoptions: {
                         size:50,                             
                         dataInit: function(elem) {
                            $(elem).autocomplete(autocompleteurl, {
                                  minChars:3,
                                scroll: true,
                                scrollHeight: 200,
                                limit:200,
                                extraParams:{catg:'Activity'},
                                autoFill: false,
                                noCache:true
                               });
                           $(elem).result(function(event, data, formatted) {
                           if (data)
                               $("#Activity1").val(data[1]);
                           });}},
                        formoptions:{label: 'Activity',elmsuffix:'<div id="act_addrow"><input id="addactRow" '+
                                                      'colspan="2" type="button" class="addRow" value="Add" />'}
                    },
                    {name:'ConceptX',index:'ConceptX', width:40, sortable:false, editable:true, editrules:{required:true},
                      editoptions:{
                        size:50,                             
                         dataInit: function(elem) {
                            $(elem).autocomplete(autocompleteurl, {
                                  minChars:3,
                                scroll: true,
                                scrollHeight: 200,
                                limit:200,
                                extraParams:{catg:'Product'},
                                autoFill: false,
                                noCache:true
                               });
                           $(elem).result(function(event, data, formatted) {
                           if (data)
                               $("#ConceptX").val(data[1]);
                           });}},                     
                        formoptions:{label: '*ConceptX', elmsuffix:'<div id="ConceptX_addrow"><input id="addConceptXRow" '+
                              'colspan="2" type="button" class="addRow" value="Add" /></div>'}
                    },   
                    {name:'ConceptY',index:'ConceptY', width:40, sortable:false, editable:true, editrules:{required:true},
                      editoptions:{
                        size:50,                             
                         dataInit: function(elem) {
                            jQuery("#associatedlist").jqGrid({
                                data: mydata,
                                datatype: "local",
                                colNames:['id','name'],
                                colModel:[
                                    {name:'id',index:'id', width:55, editable:true, editoptions:{readonly:true}, sorttype:'int'},
                                    {name:'name',index:'name', width:90, sorttype:'date', editable:true}],
                                rowNum:10,
                                rowTotal: 50,
                                rowList:[10,20,30],
                                //pager: '#pcrud',
                                sortname: 'id',
                                loadonce: true,
                                viewrecords: true,
                                sortorder: "desc",
                                editurl: 'server.jsp',
                                caption:"CRUD on Local Data" });
                        }},                     
                        formoptions:{label: '*ConceptY', elmsuffix:'<div id="ConceptX_addrow"><table id="associatedlist"><tr><td>&nbsp;</td></tr></table></div>'}
                    },                      

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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