Forum


18:07

01/09/2009

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.
04:13

Moderators
30/10/2007

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.
10:56

13/11/2009

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….
11:15

13/11/2009

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"})
}
}
);
}
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66