?
Solved

bootstrapTable

Posted on 2016-10-12
8
Medium Priority
?
234 Views
Last Modified: 2016-10-16
I am using bootStrap table in conjunction with COldFusion and its all working fine. Now I Need to add a custom toolbar menu item witch will work as a filter.

I can not get this part to work it does not update the tbale onChnage

<div id="toolbar" class="btn-group">


                    <select name="category" id="categoty" class="form-control">
                    	<option value=""> -- Select Category --</option>
                    	<cfoutput query="qGetWikiCategory">
                    		<option value="#categoryid#">#trim(categoryname)#</option>
                    	</cfoutput>
                    </select>



</div>

<div class="col-sm-12 col-md-12 col-lg-12">
            <table id="users" data-height="400" data-side-pagination="server" data-pagination="true" data-search="true"  clickToSelect="true" singleSelect="true" data-single-select="true"
            	data-toolbar="#toolbar"
            	data-show-refresh="true"
            	data-show-toggle="true"
            	<!---data-query-params="queryParams"--->
            	<!---data-response-handler="responseHandler"--->
		 		data-url="/includes/wiki.cfc?method=getWiki"
				data-show-columns="true"
				data-toolbar-align="left"
            >
            </table>
        </div>

Open in new window


$('#users').bootstrapTable({
                method: 'get',
                url: '/includes/wiki.cfc?method=getWiki',
                cache: false,
                height: 400,
                striped: true,
                pagination: true,
                pageSize: 10,
                pageList: [10, 25, 50, 100, 200],
                search: true,
                showColumns: false,
                showRefresh: true,
				singleSelect:true,
                smartDisplay	:true,
                minimumCountColumns: 2,
                clickToSelect: true,
                columns: [
				          {field: 'COUNT',title: 'WIKI #',align: 'right',valign: 'bottom',sortable: false},
						  {field: 'wikiid',title: 'Wiki ID',visible:false},
						  {field: 'name',title: 'Wiki Title',align: 'left',valign: 'middle',sortable: true},
						  {field: 'docUploaded',title: 'File Uploaded',align: 'left',valign: 'middle',sortable: true},
						  {field: 'status',title: 'Status',align: 'left',valign: 'top',sortable: true},
						  {field: 'operate',title: 'Actions',align: 'center',valign: 'middle',clickToSelect: false,formatter: operateFormatter,events: operateEvents}]
            });
    });

	function operateFormatter(value, row, index) {
        return [
            '<a class="edit ml10" href="javascript:void(0)" title="Edit">',
                '<i class="glyphicon glyphicon-edit"></i>',
            '</a>&nbsp;',
            '<a class="remove ml10" href="javascript:void(0)" title="Remove">',
                '<i class="glyphicon glyphicon-remove"></i>',
            '</a>'
        ].join('');
    }

    window.operateEvents = {
        'click .edit': function (e, value, row, index) {
            window.location.href = "addQuestion.cfm?ID=" + +row.wikiid;
        },

        'click .remove': function (e, value, row, index) {
			var conf = "Are you sure you want to delete this wiki?";
			if (conf){
			$.getJSON('/includes/wiki.cfc?method=deleteQuestion&returnformat=json&queryformat=column&_cf_nodebug=true&_cf_nocache=true&ID='+row.wikiid,
				function(d)
				{
					$('#Error').text(d.MESSAGE);
					$('#users').bootstrapTable('refresh');
				});
			}
		}
    };

$("#categoty").change(function(){

		//alert('Hello');
		//alert($(this).val());
		if ($(this).val() > 0){
			$.getJSON('/includes/wiki.cfc?method=getWiki&returnformat=json&queryformat=column&_cf_nodebug=true&_cf_nocache=true&categoryid=' + $(this).val(),
				function(d)
				{

					//$('#Error').text(d.MESSAGE);
				$('#users').bootstrapTable('refresh');
			});

		}

	})

Open in new window


ColdFusion CFC
<cffunction name="getWiki" access="remote" returnformat="plain" returntype="any">
    	<cfargument name="offset" default="0" type="numeric">
        <cfargument name="limit" default="10" type="numeric">
        <cfargument name="order" default="asc" type="string">
        <cfargument name="sort" default="wikiid" type="string">
        <cfargument name="search" default="" type="string" />
        <cfargument name="categoryid" default="" type="string" />

     	<cfquery name="getWiki" datasource="#request.datasource#">
        	WITH Rows AS
            (
				SELECT	 W.wikiid,W.name,W.wikiText,CASE WHEN W.status = 1 THEN 'Active' ELSE 'Inactive' END as status,W.docUploaded,
						 ROW_NUMBER() OVER (ORDER BY #sort# #order#) [Row]
                FROM wiki W
                inner join wikiCategory WC on WC.categoryID = W.wiki_categoryID
                WHERE 1=1
				<cfif Search NEQ "">
                    and
                    W.wikiid like '%#arguments.Search#%' OR W.name like '%#arguments.Search#%' OR W.wikiText like '%#arguments.Search#%'
                </cfif>
                <cfif arguments.categoryid neq "">
                	and WC.categoryID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.categoryid#">
                </cfif>
             )
                SELECT
                      *
                FROM
                     Rows
                WHERE Row >= #offset+1# and Row <= #offset+limit#
        </cfquery>



        <cfquery name="qCount" datasource="#request.datasource#">
        	SELECT COUNT(*) as total
            FROM wiki W
            inner join wikiCategory WC on WC.categoryID = W.wiki_categoryID
            WHERE 1=1
            <cfif Search NEQ "">
                and
                W.wikiid like '%#arguments.Search#%' OR name like '%#arguments.Search#%' OR wikiText like '%#arguments.Search#%'
            </cfif>
             <cfif arguments.categoryid neq "">
                	and WC.categoryID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.categoryid#">
                </cfif>
        </cfquery>

        <cfset resultStruct = Structnew() />
      	<cfset resultStuct["total"] = qCount.total />
        <cfset resultStuct["rows"] = ArrayNew(1) />
      	<cfset count = 1/>
      	<cfloop query="getWiki" >
            <cfset resultStuct["rows"][count]['COUNT'] =  Count />
			<cfset resultStuct["rows"][count]['wikiid'] =  getWiki.wikiid />
			<cfset resultStuct["rows"][count]['name'] =  getWiki.name />
            <cfset resultStuct["rows"][count]['wikiText'] =  getWiki.wikiText />
            <cfset resultStuct["rows"][count]['status'] =  getWiki.status />
             <cfset resultStuct["rows"][count]['docUploaded'] =  getWiki.docUploaded />
            <cfset Count = Count + 1/>
      	</cfloop>

      	<cfreturn SerializeJSON(resultStuct) />
    </cffunction>

Open in new window

0
Comment
Question by:erikTsomik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 19

Author Comment

by:erikTsomik
ID: 41841324
Any suggestions
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41841678
1. Is the $.getJSON firing - have you checked the console to see if it is and what it is returning
2. What does the $.getJSON do - you don't appear to be using the return'd value which begs the question why you are using $.getJSON and not just $.get

I tried to look at the docs for bootstraptable but the site is not responding currently - but I am going to assume that the refresh action is meant to re-get the data - do you see any evidence of this in the console?
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 41841810
0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41841840
I posted a couple of questions - do you have answers for those?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 41842137
erikTsomik - Did you mean to hit "Delete Question"? Seems like you found a solution. If so it should be added to the archives to help the next person with the same problem.
0
 
LVL 19

Accepted Solution

by:
erikTsomik earned 0 total points
ID: 41842167
The solution

$("#categoty").change(function(){
                  $('#users').bootstrapTable('refresh',{query: {categoryid: $(this).val()}});
            })
0
 
LVL 52

Expert Comment

by:_agx_
ID: 41842681
Posting this objection to stop the auto deletion process, since a solution was found and posted
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question