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
jqGridImport problem
31/08/2009
18:07
Avatar
alek
New Member
Members
Forum Posts: 2
Member Since:
01/09/2009
sp_UserOfflineSmall Offline

Hi,

I've got really big problems with importing structure of the grid and reloading it back to the grid.

The example is very simple:

jQuery("#list9").jqGrid({
       url: '/base_url/listing_request_jqgrid_json/',
    datatype: "json",
    mtype: 'POST',
       colNames:['ID','Nazwa','PeÅ‚na nazwa'],  
colModel:[{name:'id', index:'id', width:55, align:'center',editable:true,editoptions:{size:25}}
,{name:'name', index:'name', width:55, align:'center',editable:true,editoptions:{size:25}}
,{name:'printable_name', index:'printable_name', width:55, align:'center',editable:true,editoptions:{size:25}}
],
          rowNum:10,
       rowList:[10,20,30],
       imgpath: gridimgpath,
       pager : "#pager9",
       sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
    multiselect: false,
    width: 500,
    height: "100%",
    editurl:'/base_url/edit_request_ajax/',
    caption: "Auto height example"
}).navGrid('#pager9',{edit:false,add:false,del:false});

$(document).ready( function() {
jQuery("#gridconf").click( function() {
    alert("before");
    var s = $("#list9").jqGridExport({exptype:"xmlstring"});
    alert(s);
    $("#txmlarea").val(s);
});

jQuery("#gridconfget").click( function() {
    alert("alik2");
     $("#list9").jqGridImport({impurl:"/base_url/get_listing_view", imptype: "xml", mtype: "POST", importComplete: function(){jQuery("#list9").trigger("reloadGrid");alert("reloaded");} });
    alert("after");
});
});

When i try to make an click action on jQuery("#gridconfget") everything works okey but I'm not seeing any results (I'm seeing "reloaded" alert).

The xml which is returned by the /base_url/get_listing_view url (and jQuery("#gridconf").click function) is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<roots>
<grid><url>/spam_main/kraje/listing_request_jqgrid_json/</url><height>100%</height><page>1</page><rowNum>10</rowNum><records>240</records><pager>#pager9</pager><pgbuttons>true</pgbuttons><pginput>true</pginput> <colModel> <name>id</name> <index>id</index> <width>161</width> <align>center</align> <editable>true</editable> <editoptions> <size>25</size></editoptions> <hidden>false</hidden> <resizable>true</resizable> <sortable>true</sortable></colModel>
	<colModel>		<name>name</name>		<index>name</index>		<width>161</width>		<align>center</align>		<editable>true</editable>		<editoptions>			<size>25</size></editoptions>		<hidden>false</hidden>		<resizable>true</resizable>		<sortable>true</sortable></colModel>
	<colModel>		<name>printable_name</name>		<index>printable_name</index>		<width>163</width>		<align>center</align>		<editable>true</editable>		<editoptions>			<size>25</size></editoptions>		<hidden>false</hidden>		<resizable>true</resizable>		<sortable>true</sortable></colModel>
	<rowList>10</rowList>
<rowList>20</rowList>
<rowList>30</rowList>
<colNames>ID</colNames>
<colNames>Nazwa</colNames>
<colNames>Pełna nazwa</colNames>
<sortorder>desc</sortorder><sortname>id</sortname><datatype>json</datatype><mtype>POST</mtype><altRows>false</altRows><selarrrow>__EMPTY_ARRAY_</selarrrow>
<savedRow>__EMPTY_ARRAY_</savedRow>
<shrinkToFit>true</shrinkToFit><xmlReader> <root>rows</root> <row>row</row> <page>rows>page</page> <total>rows>total</total> <records>rows>records</records> <repeatitems>true</repeatitems> <cell>cell</cell> <id>[id]</id> <userdata>userdata</userdata> <subgrid> <root>rows</root> <row>row</row> <repeatitems>true</repeatitems> <cell>cell</cell></subgrid></xmlReader><jsonReader> <root>rows</root> <page>page</page> <total>total</total> <records>records</records> <repeatitems>true</repeatitems> <cell>cell</cell> <id>id</id> <userdata>userdata</userdata> <subgrid> <root>rows</root> <repeatitems>true</repeatitems> <cell>cell</cell></subgrid></jsonReader><subGrid>false</subGrid><subGridModel>__EMPTY_ARRAY_</subGridModel>
<reccount>10</reccount><lastpage>24</lastpage><lastsort>0</lastsort><selrow/><beforeSelectRow/><onSelectRow/><onSortCol/><ondblClickRow/><onRightClickRow/><onPaging/><onSelectAll/><loadComplete/><gridComplete/><loadError/><loadBeforeSend/><afterInsertRow/><beforeRequest/><onHeaderClick/><viewrecords>true</viewrecords><loadonce>false</loadonce><multiselect>false</multiselect><multikey>false</multikey><editurl>/spam_main/kraje/edit_request_ajax/</editurl><search>false</search><caption>Auto height example</caption><hidegrid>true</hidegrid><hiddengrid>false</hiddengrid><postData>	<_search>false</_search>	<nd>1251583944040</nd>	<rows>10</rows>	<page>1</page>	<sidx>id</sidx>	<sord>desc</sord></postData><userData>	<amount>0</amount>	<tax>0</tax>	<total>0</total>	<name>Totals:</name></userData><treeGrid>false</treeGrid><treeGridModel>nested</treeGridModel><treeReader/><treeANode>-1</treeANode><ExpandColumn/><tree_root_level>0</tree_root_level><prmNames>	<page>page</page>	<rows>rows</rows>	<sort>sidx</sort>	<order>sord</order>	<search>_search</search>	<nd>nd</nd></prmNames><forceFit>false</forceFit><gridstate>visible</gridstate><cellEdit>false</cellEdit><cellsubmit>remote</cellsubmit><nv>0</nv><loadui>enable</loadui>	<toolbar>false</toolbar>
	<toolbar>__EMPTY_STRING_</toolbar>
<scroll>false</scroll><multiboxonly>false</multiboxonly><deselectAfterSort>true</deselectAfterSort><scrollrows>false</scrollrows><autowidth>false</autowidth><scrollOffset>18</scrollOffset><cellLayout>5</cellLayout><subGridWidth>20</subGridWidth><multiselectWidth>20</multiselectWidth><gridview>false</gridview><rownumWidth>25</rownumWidth><rownumbers>false</rownumbers><pagerpos>center</pagerpos><recordpos>right</recordpos><footerrow>false</footerrow><userDataOnFooter>false</userDataOnFooter><hoverrows>true</hoverrows><altclass>ui-priority-secondary</altclass> <viewsortcols>false</viewsortcols>
	<viewsortcols>vertical</viewsortcols>
<viewsortcols>true</viewsortcols>
<resizeclass>__EMPTY_STRING_</resizeclass><autoencode>false</autoencode><recordtext>View {0} - {1} of {2}</recordtext><emptyrecords>No records to view</emptyrecords><loadtext>Loading...</loadtext><pgtext>Page {0} of {1}</pgtext><imgpath>themes/basic/images</imgpath><width>500</width><id>list9</id><keyIndex>false</keyIndex><tblwidth>485</tblwidth><_height>64</_height> <_nvtd>138</_nvtd>
	<_nvtd>40</_nvtd>
<totaltime>117</totaltime></grid></roots>

Exactly the same problem occurs when I use jsonstring.
02/09/2009
04:24
Avatar
alek
New Member
Members
Forum Posts: 2
Member Since:
01/09/2009
sp_UserOfflineSmall Offline

Hi,

Can anyone give me some tip on reloading grid with imported settings? Any working example..

Thanks

04/09/2009
04:13
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

As I understand you try to import the new configuration on already created grid.

Directly this is not possible. You should use a method to unload the grid, something like:

jQuery(”#gridconfget”).click( function() {

   $(”#list9″).GridUnload();
     $(”#list9″).jqGridImport({impurl:”/base_url/get_listing_view”, imptype: “xml”, mtype: “POST” });
});

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.

13/11/2009
10:56
Avatar
adobepro
Member
Members
Forum Posts: 4
Member Since:
13/11/2009
sp_UserOfflineSmall Offline

Hi Tony,

After reading your last post on here, I finally got the configuration to apply to the grid from an xml source export.

However, when I try to recreate the nav, it doesn't work — I do not get any error, but I can't add to the nav.

Looking at the GridUnload method, it's seems like I wont be able to? I imported with and without the grid unload method,

and both times, the nav was not created. Any help would be greatly appreciated with this.

Also, if I have to use GridUnload to restore the configuration state, would editing still work on the row cells?

I haven't needed to make editable cells yet, but when/if I do, would editing still work?

Thanks,

Alex

gridunload()

[The only difference to previous method is that the grid is destroyed, but the table element and pager

(if any) are left ready to be used again.]

function restore_grid_state()
   {

        //$JQuery(”#scrolling”).jqGrid(jqObject);

        //$JQuery(”#scrolling”).jqGrid('GridUnload');
        $JQuery(”#scrolling”).jqGrid('jqGridImport',

           {impurl:”/report_preferences.php?pid=pref_object_state&action=restore&sid=demotest&aid=p&uid=23”,
            imptype: “xml”,
             mtype: “GET”
           }
        );

        $JQuery(”#scrolling”).jqGrid(”navGrid”,”#pscrolling”,{edit:false,add:false,del:false,search:true,refresh:true,columnChooser:true}).jqGrid('navButtonAdd','#pscrolling',{caption:”Add/Remove Columns”,
            onClickButton: function (){ $JQuery(”#scrolling”).jqGrid('setColumns',{width:500,afterSubmitForm: function (){ store_grid_state(); }}); }, position:”first”})

code continues….

13/11/2009
11:15
Avatar
adobepro
Member
Members
Forum Posts: 4
Member Since:
13/11/2009
sp_UserOfflineSmall Offline

Kept on browsing this issue on other threads in the forum, and found a solution [needed to add in the importComplete method]

Thanks!

Alex

   function restore_grid_state()
   {

        $JQuery("#scrolling").jqGrid('jqGridImport',

           {impurl:"/report_preferences.php?pid=pref_object_state&action=restore&sid=demotest&aid=p&uid=37",
            imptype: "xml",
             mtype: "GET",importComplete:function()
           {
                $JQuery("#scrolling").jqGrid("navGrid","#pscrolling",{edit:false,add:false,del:false,search:true,refresh:true,columnChooser:true}).jqGrid('navButtonAdd','#pscrolling',{caption:"Add/Remove Columns",
            onClickButton: function (){ $JQuery("#scrolling").jqGrid('setColumns',{width:500,afterSubmitForm: function (){ store_grid_state(); }}); }, position:"first"})

           }
           }
        );
}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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