locked
Lightswitch HTML CLIENT - Disable Table Column Sorting RRS feed

  • Question

  • Hello, 

    Is there any way i can disable the column sorting when i click a column Name?

    Best regards,
    johny

    Tuesday, September 1, 2015 2:51 PM

Answers

  • Hi Johny,

    we use follow code in the postRender:

    var table = $("table", $(element));
    
    // When the element was found.
    if (table.length > 0) {
    	// Search EventHandler
    	var clickEvent = $._data(table[0], "events").vclick;
    
    	// Content
    	var content = $("tbody", $(element));
    
    	// Pass through handler click event
    	$.each(clickEvent, function (j, h) {
    		// Assign the content handler
    		conten.bind("vclick", h.handler);
    	})
    
    	// Remove click event header
    	table.unbind("vclick");
    
    	// Pass through Table Headers
    	$("th", $(element)).each(function (i) {
    
    		// Sort Remove
    		$(this).removeClass("ui-btn");
    		$(this).removeClass("ui-btn-up-a");
    		
    		// Background Color
    		$(this).css({
    			"color": "white",
    			"background-color": "steelblue"
    		});
    
    	});
    
    	// Border arround the table 
    	table.css({
    		"border-width": "1px",
    		"border-style": "solid",
    		"border-color": "steelblue"
    	});
    }

    I hope it helps.

    Regards

    j.nord

    • Marked as answer by Johny Pingo Wednesday, September 2, 2015 8:50 AM
    Wednesday, September 2, 2015 8:22 AM

All replies

  • Hi Johny Pingo,

    Please try with custom control. You can create a custom control used to display data which can't sort by columns. Please refer to following article which introduce custom controls and Data Binding in LightSwitch HTML client. Hope it can help you.
    http://blogs.msdn.com/b/lightswitch/archive/2012/12/06/custom-controls-and-data-binding-in-the-lightswitch-html-client-joe-binder.aspx
     
    Best Regards,
    Weiwei

    Wednesday, September 2, 2015 5:33 AM
    Moderator
  • Hi Johny,

    we use follow code in the postRender:

    var table = $("table", $(element));
    
    // When the element was found.
    if (table.length > 0) {
    	// Search EventHandler
    	var clickEvent = $._data(table[0], "events").vclick;
    
    	// Content
    	var content = $("tbody", $(element));
    
    	// Pass through handler click event
    	$.each(clickEvent, function (j, h) {
    		// Assign the content handler
    		conten.bind("vclick", h.handler);
    	})
    
    	// Remove click event header
    	table.unbind("vclick");
    
    	// Pass through Table Headers
    	$("th", $(element)).each(function (i) {
    
    		// Sort Remove
    		$(this).removeClass("ui-btn");
    		$(this).removeClass("ui-btn-up-a");
    		
    		// Background Color
    		$(this).css({
    			"color": "white",
    			"background-color": "steelblue"
    		});
    
    	});
    
    	// Border arround the table 
    	table.css({
    		"border-width": "1px",
    		"border-style": "solid",
    		"border-color": "steelblue"
    	});
    }

    I hope it helps.

    Regards

    j.nord

    • Marked as answer by Johny Pingo Wednesday, September 2, 2015 8:50 AM
    Wednesday, September 2, 2015 8:22 AM
  • Thanks j.nord, that really helped.

    I was only trying to remove the click event, and suspecting that i also had to remove the class's associated to the Sort, but didn't knew exactly how to do it.

    Thanks again, best regards.
    johny
    Thursday, September 3, 2015 8:49 AM