jQWidgets Forums

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts

  • Mr.Moo
    Participant

    Hello Dimitar,

    Thank you. You are of course correct the issue was down to me not complying with the required structure as outlined in the link from message No. 3. I have since changed HTML the python generates and using a jQuery filter I extract the root level div tag to display in the window.


    Mr.Moo
    Participant

    Thanks Dimitar,

    I now have this working. But what I would like to do on the uploadEnd event is to display the HTML page response to the user in a popup window. I have seen what I think is a similar thing here (http://www.jqwidgets.com/community/topic/dynamic-modal-window/) but for me this did nothing, I suspect due to the fact that my file upload window is modal.

    Is there a way to do this?


    Mr.Moo
    Participant

    Hi Peter,

    Thanks for pointing me in the right direction.

    Looking at the documentation I note that .toFixed() returns a string so explains why the % symbol was being lost. So to fix it I prepended my return statement with a +. i.e. return +(MyPercentCalc).toFixed(2)

    Moo


    Mr.Moo
    Participant

    OK, I now know why this version of the code displays my Percent() value, and that is because it is using a ko.observableArray(), if this is changed to a $.jqx.observableArray() ‘function() g()’ is displayed instead, is there an explanation for this?

    So I made the same change to my project code and it now all works as expected, with one exception and that is the display of a ko.observableArray‘s values in a grid; is this even possible?


    Moo


    Mr.Moo
    Participant

    An update to the above post. I did some reading and when I use the replace method on the observableArray to change a daysDone value and call the Percent method from the CLI I get new updated value, so this is progress, but I still have the function g()… in the UI. To see what the ellipse (…) were referring to I expanded the column and I can now see “function g(){if(0”.

    In an attempt to track this issue down, I decided to do a minimal grid, the code of which is below. However, to add insult to injury this version displays the Percent complete data but doesn’t display the values from either an observable or observableArray, but the standard HTML element data-bind displays their values!

    If you want to use this file, you will need to modify the paths in the <script> and <link>s

    <!DOCTYPE html>
    <html>
    	<head>
    		<title>Widget Test</title>
    		<meta charset="UTF-8">
    		<link type="text/css" href="./jqwidgets/styles/jqx.base.css" rel="stylesheet" />
    		<link type="text/css" href="./jqwidgets/styles/jqx.black.css" rel="stylesheet" />
    		<script src="https://code.jquery.com/jquery-2.1.4.js" type="text/javascript" ></script>
    		<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js" type="text/javascript" ></script>
    		<script src="./jqwidgets/jqxcore.js" type="text/javascript" ></script>
    		<script src="./jqwidgets/jqxdata.js" type="text/javascript" ></script>
    		<script src="./jqwidgets/jqxgrid.js" type="text/javascript" ></script>
    		<script src="./jqwidgets/jqxgrid.selection.js" type="text/javascript" ></script>
    		<script src="./jqwidgets/jqxscrollbar.js" type="text/javascript" ></script>
    		<script src="./jqwidgets/jqxbuttons.js" type="text/javascript" ></script>
    		<script>
    		var TestItem = function(item) {
    			var self = this ;
    			self.Title = "Test Item" ;
    			self.doneDays = ko.observableArray() ;
    			ko.utils.arrayForEach(item.doneDays.split(','), function(i) { self.doneDays.push(i -0) ; });
    			self.totalDays = ko.observable(item.totalDays) ;
    			self.Percent = ko.computed(function() { 
    				var p = 0 ; 
    				ko.utils.arrayForEach(self.doneDays(), function(i) { p += i ; }); 
    				return ((p / self.totalDays()) * 100).toFixed(2) ; 
    			});
    		} ;
    		
    		var Item = new TestItem({"doneDays": "1,2,3,4", "totalDays": 369 }) ;
    		
    		var data = ko.observableArray() ;
    		data.push(Item) ;
    		
    		$(document).ready( function() {
    				try {
    				var source = {
    					datatype: 'observableArray', localdata: data, datafields: [
    					{ name: 'Title', type: 'string'},
    					{ name: 'Total', type: 'int' },
    					{ name: 'Done', type: 'string' },
    					{ name: 'Percent', type: 'float' }
    					],
    				};
    				var dataAdapter = new $.jqx.dataAdapter(source) ;
    				$("#grid").jqxGrid({
    					source: dataAdapter,
    					columns: [
    					{ text: 'Legend', datafield: 'Title'},
    					{ text: 'Total Days', datafield: 'totalDays' },
    					{ text: 'Done Days', datafield: 'doneDays' },
    					{ text: '% Complete', datafield: 'Percent' }
    					]
    				}) ;
    			}
    			catch (err) {
    				console.log(err) ;
    			}
    			ko.applyBindings(Item) ;
    		});
    		</script>
    	</head>
    	<body>
    		<div style="width: 100%; height: 100%; margin-top: 10px;" id="test">
    		Legend : <span data-bind="text: Title"></span></br>
    		Total Days : <span data-bind="text: totalDays"></span></br>
    		Done Days : <span data-bind="text: doneDays"></span></br>
    		Percent % : <span data-bind="text: Percent"></span>
    		</div>
    		<div id="grid"></div>
    	</body>
    </html>

    Mr.Moo
    Participant

    Me again,

    Well I’ve re-work the code and reviewed the initrowdetails as suggested, but as this is for the ‘nested’ detail grid that produces the correct results from an existing ko.computed() I could see nothing wrong with it even after changing it to resemble that used in the demo.

    I also corrected the code that populated my arrays as reduce() evidently isn’t a function of ko.observableArrays but as I never got any complaints about it I assumed that it was working, but while debugging I realised it was wrong and fixed it.

    Now when I call my corrected Percent() function from the debug console I get the result I would expect, however, I still get `function g()’ appearing in the UI.

    What I have noticed is that if I change the values used in calculating the Percent() then call the function the returned value does not change! I simply cannot see what I am doing wrong and it’s driving me to distraction.


    Moo


    Mr.Moo
    Participant

    Thanks Peter,

    I’ll have a look tomorrow and post an update.


    Moo


    Mr.Moo
    Participant

    Hello Ivailo,

    This works for me thank you very much. I’ll make some changes to my code so I can hopefully make use of this approach.


    Moo


    Mr.Moo
    Participant

    Hello again,

    apologies for the delay in replying. I have tried the above example but the buttons still work as expected. For example, if you change the initial values thus:

    this.disabledButtonAdd = ko.observable(true);
    this.disabledButtonDelete = ko.observable(true);

    Then load the page you can still add and delete the items when you click what appears to be a disabled button! Also, how would you change the value of this.disabledButtonDelete at runtime?


    Moo


    Mr.Moo
    Participant

    Thank you for the reply, but I did suspect it was short of what you would need. So I am going to compose an email to your support team and provide the sources in the email.


    Mr.Moo
    Participant

    Thank you once again, your quality of support is exceptional.

    Moo

    in reply to: Loader image Loader image #76980

    Mr.Moo
    Participant

    I don’t know why it wasn’t in the version I had which may not have been 3.9 but 3! Anyway, it is all sorted and working. Thanks.


    Mr.Moo
    Participant

    Hello ivailo, that’s great news and all I really want to be honest, but can you tell me how I do this for a button created dynamically as shown in the jqxGrid with Statusbar example as I see no data binding references in the button’s API documentation.

    in reply to: Loader image Loader image #76917

    Mr.Moo
    Participant

    Is this widget part of the paid version as I don’t have it in my source v3.9.0 and would like to make use of it.


    Moo


    Mr.Moo
    Participant

    http://www.jqwidgets.com/community/topic/jqxbutton-enable-binding/

    Link binding did not work so here is the reference.

Viewing 15 posts - 1 through 15 (of 18 total)