EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kush on November 01, 2014, 04:25:51 AM



Title: How to give class name to datagrid column fields
Post by: kush on November 01, 2014, 04:25:51 AM
I have a requirement of loading dynamic columns on click of a left arrow.For that i am looping over "table th" array  with class name.And have given Class name to th fields from markup.

<th class="monthTd" field="jan 14" width="80">Jan 14</th>
<th class="monthTd" field="Feb 14" width="80">Feb 14</th>
<th class="monthTd" field="Mar 14"  width="80">Mar 14</th>
<th class="monthTd" field="Apr 14" width="80">Apr 14</th>
<th class="monthTd" field="May 14" width="80">May 14</th>
<th class="monthTd" field="Jun 14" width="80">Jun 14</th>
<th class="monthTd" field="Jul 14"  width="80">Jul 14</th>
<th class="monthTd" field="Aug 14" width="80">Aug 14</th>
<th class="monthTd" field="Sep 14" width="80">Sep 14</th>
<th class="monthTd" field="Oct 14"  width="80">Oct 14</th>
<th class="monthTd" field="Nov 14" width="80">Nov 14</th>
<th class="monthTd" field="Dec 14" width="80">Dec 14</th>

$('th.monthTd').each(function(m) {}   ----Looping th array with class name..
But the problem is on click of right arrow months will move to next months with columns.
for that i need to everytime call datagrid with modified columns array.
$('#dg').edatagrid({
             columns:[new set of th fields],
         });
For first time its dynamically changing column headers because the .monthTd is found in markup.
Next time when i filled dynamically from datagrid classname become empty.

So i want to set class name in my columns array.pls look into attachment nd do reply.

[ { title="Apr 2014", field="Apr 2014", width=80},{ title="Apr 2014", field="Apr 2014", width=80}]


Title: Re: How to give class name to datagrid column fields
Post by: kush on November 01, 2014, 09:00:48 PM
Please let me know if i can give class name to columns fields from javascript.Becuase Jeasyui handling my markup tags to display none , and its tags dynamically to datagrid without my class name.


Title: Re: How to give class name to datagrid column fields
Post by: stworthy on November 02, 2014, 11:41:15 PM
Why do you want to set a class name to the columns? To create datagrid with specified columns, just define the 'columns' property.
Code:
$('#dg').edatagrid({
  columns:[[
    {...}
  ]]
});